gpt4 book ai didi

iphone - UITextView iPhone中的渐变效果?

转载 作者:行者123 更新时间:2023-12-01 18:19:47 24 4
gpt4 key购买 nike

我正在做一个需要在 UITextView 中实现中心渐变的项目。它必须类似于附加图像。我不能在 UITextView 上方使用任何图像,因为我希望在 UITextView 中进行用户交互。请提供您的建议。谢谢

enter image description here

最佳答案

If you apply CAGRradient Layer on UITextView and set [txtView.layer setMask:gradient] this will create problem while scrolling means the gradient layer will scroll. To overcome from this problem you must use a UiView working as a container view for your textView. first of all add your container view and then add your text view as subview in your container view. and then use this code which save my life.


 CAGradientLayer  gradient = [CAGradientLayer layer];
gradient.frame = view_bottomMenu.bounds;
gradient.colors = [NSArray arrayWithObjects:(id)[[[UIColor blackColor colorWithAlphaComponent:0.2] CGColor],(id)[[[UIColor blackColor] colorWithAlphaComponent:0.3] CGColor],(id)[[[UIColor blackColor] colorWithAlphaComponent:0.3] CGColor],(id)[[[UIColor blackColor] colorWithAlphaComponent:0.3] CGColor], (id)[[[UIColor clearColor] colorWithAlphaComponent:1.0] CGColor], (id)[[[UIColor blackColor] colorWithAlphaComponent:0.3] CGColor],(id)[[[UIColor blackColor] colorWithAlphaComponent:0.3] CGColor],(id)[[[UIColor blackColor] colorWithAlphaComponent:0.3] CGColor],
(id)[[[UIColor blackColor] colorWithAlphaComponent:0.2] CGColor], nil];

gradient.startPoint = CGPointMake(0.0f,0.0f);
gradient.endPoint = CGPointMake(0.0f, 1.0f);

[view_bottomMenu.layer setMask:gradient];

where view_bottomMenu is UIView working as container view.here is my output. enter image description here

关于iphone - UITextView iPhone中的渐变效果?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18355106/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com