如何在 iOS UITextView
中实现与下图相同的效果。
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/