大佬教程收集整理的这篇文章主要介绍了ios – 在UITextView中获取CGRect文本,以便用CALayer突出显示,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
NSRange match = [[[self textView]text]rangeOfString:@"preDict the future"]; NSRange glyphRange = [manager glyphRangeForCharacterRange:match actualCharacterRange:NULL]; CGRect textRect = [manager boundingRectForGlyphRange:glyphRangE intextContainer:[[self textView]textContainer]]; CGPoint textViewOrigin = self.textView.frame.origin; textRect.origin.x += (textViewOrigin.x / 2); textRect.origin.y += (textViewOrigin.y / 2); CALayer* roundRect = [CALayer layer]; [roundRect setFrame:textRect]; [roundRect setBounds:textRect]; [roundRect setCornerRadius:5.0f]; [roundRect setBACkgroundColor:[[UIColor blueColor]CGColor]]; [roundRect setOpacity:0.2f]; [roundRect setBorderColor:[[UIColor blackColor]CGColor]]; [roundRect setBorderWidth:3.0f]; [roundRect setShadowColor:[[UIColor blackColor]CGColor]]; [roundRect setShadowOffset:CGSizeMake(20.0f,20.0f)]; [roundRect setShadowOpacity:1.0f]; [roundRect setShadowRadius:10.0f]; [[[self textView]layer]addSublayer:roundRect];@H_696_5@如果我移动文本字段,或者如果我不将偏移量除以2,则得到以下结果: @H_696_5@我想知道我是否在正确的轨道上,以及如何找到NSTextContainer对象的起源.
以上是大佬教程为你收集整理的ios – 在UITextView中获取CGRect文本,以便用CALayer突出显示全部内容,希望文章能够帮你解决ios – 在UITextView中获取CGRect文本,以便用CALayer突出显示所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。