使用渐变缩放 UIView
我正在开发一个动画柱形图,但遇到了一些麻烦。 条形图以缩放动画显示。开始时,所有列的大小均为 1 磅,并将缩放至预定义的高度。
要点是:我想在列中绘制渐变(它们是 UIView 的子类)并希望缩放动画重新计算渐变。
到目前为止,我已经绘制了渐变,但是当列缩放时,渐变不会随之缩放。 由于视图的高度为 1 点,因此渐变仅显示为 1 种颜色。
有人可以给我一个北来解决这个问题吗?
I'm developing an animated column bar chart and i having some trouble.
The bars show up with an scale animation. At the beginning all columns have 1 point size and will scale till a predefined height.
The point is: I want to draw a gradient into the columns (They are subclasses of UIView) and want the scale animation to recalculate the gradient.
Until now, i have drawn the gradient, but when the column scale, the gradient does not scale with it.
As the view have 1 point height, the gradient is show as 1 color only.
Can someone give me a north to solve this issue?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
解决了问题!
我使用比例而不是更改视图的边界..
Was
必须是
之前计算过的scaleY,并且是包含Y 比例因子的NSNumber。
不需要设置
谢谢DarkDusk的帮助。
Solved the problem!
i was using scale instead of changing the view's bounds..
Was
Must be
Where scaleY was calculated before and is a NSNumber that contains the Y scale factor.
It's not necessary to set
Thank you DarkDusk for the help.
尝试设置
contentMode
:这将强制在每次大小更改时重绘。
Try setting the
contentMode
:This will force a redraw on every size change.