星空网 > 软件开发 > 操作系统

TextView表情文字混排

2015-10-27

- (void)layoutSubviews {    skContentView.backgroundColor = self.backgroundColor;  skContentView.frame = self.bounds;    NSMutableAttributedString * string = [[ NSMutableAttributedString alloc ] initWithString:@"123456789101112计算" attributes:nil ] ;  [string addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:16.0] range:NSMakeRange(0,string.length-1)];    MMTextAttachment * textAttachment = [[ MMTextAttachment alloc ] initWithData:nil ofType:nil ] ;  UIImage * smileImage = [ UIImage imageNamed:@"a.jpg" ] ; //my emoticon image named a.jpg  textAttachment.image = smileImage ;    NSAttributedString * textAttachmentString = [ NSAttributedString attributedStringWithAttachment:textAttachment ] ;  [ string insertAttributedString:textAttachmentString atIndex:6 ] ;    _skInputTextView.attributedText = string ;}

 

@interface MMTextAttachment : NSTextAttachment {  }@end@implementation MMTextAttachment//图片大小与文字保持一致- (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

 




原标题:TextView表情文字混排

关键词:ie

ie
*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。

亚马逊广告答疑:同一个词打精准又打词组,会冲突吗?:https://www.kjdsnews.com/a/699037.html
eBay缺货怎么处理?eBay“无货在线”功能设置:https://www.kjdsnews.com/a/699038.html
法国EPR,亚马逊动真格啦!:https://www.kjdsnews.com/a/699039.html
新规倒计时!亚马逊发出“最后通牒”,不合规产品或被禁售!:https://www.kjdsnews.com/a/699040.html
省钱!亚马逊库存管理技巧,无形中提高店铺利润(建议收藏):https://www.kjdsnews.com/a/699041.html
黑五网一复盘:黑五网一复盘:https://www.kjdsnews.com/a/699042.html
2024.03.29亚马逊选品推荐(仅供参考):宠物饮水机滤芯片:https://www.kjdsnews.com/a/1836532.html
想要搞钱,就去做离搞钱最近的事:https://www.kjdsnews.com/a/1836533.html
相关文章
我的浏览记录
最新相关资讯
海外公司注册 | 跨境电商服务平台 | 深圳旅行社 | 东南亚物流