更改 UIScrollView 内的 alpha
我试图实现让文本淡入淡出的效果,以显示这篇文章中 UIScrollView 中有更多数据: UIScrollView,通过淡出文本显示更多数据
我无法让 CAGradientLayer 看起来正确,因为我的背景不是简单的黑白背景,我无法让它匹配并使其看起来像文字正在褪色。所以我想我应该尝试在 UIScrollView 内设置 alpha 属性,或者在 UIScrollView 内设置 UILabel 的 alpha 。但是,它会更改所有文本的 Alpha。有没有办法只对文本的一部分或滚动视图的一部分执行此操作?谢谢!
I was trying to achieve the effect of having my text fade in and out to show there is more data in the UIScrollView in this post: UIScrollView, showing that there is more data by fading out text
I could not get the CAGradientLayer to look right since my background isn't a simple black and white background and I couldn't get it to match and make it look like the text is fading. So I thought I'd try setting the alpha property inside the UIScrollView, or the UILabel's alpha inside the UIScrollView. However, it changes all the text's alpha. Is there a way to do it for only a portion of the text, or a portion of the scrollView? Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
有多种方法,其中至少有两种相当简单:
#include
。There are several ways, at least two of which are reasonably easy:
view.layer.maskLayer
on an appropriate view (a UIView containing the scroll view should work) to something suitable (e.g. a CALayer with contents/contentsScale/contentsCenter set appropriately). More of a pain, since CALayer does not autosize itself (so your wrapper view will have to do the necessary things in -setFrame:/-setBounds:/-layoutSubviews). You'll need to#include <QuartzCore/CALayer.h>
.