ios - UITextview底部的渐变层

标签 ios ios5 ios7 uitextview

如何在 iOS UITextView 中实现与下图相同的效果。 UITextView

底部的模糊效果

Gradient at the bottom of UItextView

提前致谢:)

最佳答案

尝试以下操作:我尝试使用图像但不是 UITextView

UIView *vwTest = [[UIView alloc] initWithFrame:_textView.frame];
[vwTest setBackgroundColor:[UIColor whiteColor]];
[vwTest setUserInteractionEnabled:NO];
[self.view addSubview:vwTest];

NSArray *colors = [NSArray arrayWithObjects:
                   (id)[[UIColor colorWithWhite:0 alpha:1] CGColor],
                   (id)[[UIColor colorWithWhite:0 alpha:0] CGColor],
                   nil];

CAGradientLayer *layer = [CAGradientLayer layer];
[layer setFrame:vwTest.bounds];
[layer setColors:colors];
[layer setStartPoint:CGPointMake(0.0f, 1.0f)];
[layer setEndPoint:CGPointMake(0.0f, 0.6f)];
[vwTest.layer setMask:layer];

关于ios - UITextview底部的渐变层,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21816052/

相关文章:

ios - Apple 由于崩溃而拒绝了我的应用程序,无法重现

iOS7 UITextView 自动调整文本大小

ios - iOS 中的 GPUImage 二值化

sqlite - 核心数据轻量级迁移 : what's required to trigger it?

mysql - 在 xcode 应用程序中显示 WordPress 帖子的最佳方式?

ios - 运行 swift 示例而不是 objective c 示例

ios - 带有 NSTimers 和服务器调用的后台模式

ios - SpriteKit 多向滚动

objective-c - UIScrollview 中的 UIView 中的 UIButton,ARC 问题

objective-c - 从 UIWebView 移除阴影