iOS 7 UITextView: Size of nstextattachment getting 2x after reopening the application

白昼怎懂夜的黑 提交于 2019-12-05 05:15:43

Could the reason due to retina display? If it is retina, you might need to reduce the size by 50% before storing. How about trying this:-

 //Original Size that you want to store
CGSize imageSize = CGSizeMake(320.0f, 320.0f);

//Make the image 50% of the size for retina
if ([[UIScreen mainScreen] respondsToSelector:@selector(displayLinkWithTarget:selector:)] &&([UIScreen mainScreen].scale == 2.0)) {
    // Retina display
    imageSize = CGSizeMake(160.0f, 160.0f);
}

UIImage * storeImage = [self imageWithImage:self.image scaledToSize:imageSize]
//TODO: Store this image locally or whatever you want to do.
@interface MMTextAttachment : NSTextAttachment
{
}
@end
@implementation MMTextAttachment
//I want my emoticon has the same size with line's height
- (CGRect)attachmentBoundsForTextContainer:(NSTextContainer *)textContainer proposedLineFragment:(CGRect)lineFrag glyphPosition:(CGPoint)position characterIndex:(NSUInteger)charIndex NS_AVAILABLE_IOS(7_0)
{
return CGRectMake( 0 , 0 , lineFrag.size.height , lineFrag.size.height );
}
@end

I think you can try this.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!