使用 UIImages 在 iPhone 上显示进度条
我正在为一个应用程序设计一个进度条,它本质上是两个 UIImages - 两者的大小完全相同(带圆角的长矩形),只是它们的颜色不同。
底部栏是黑色的,覆盖它的进度栏是灰色的。显示底部栏非常简单。我想解决的问题是如何让灰色条仅显示其自身的一部分。
例如....
灰色:<--------
白色:<-------------------->
本质上,我只想显示灰色条的前半部分,因为我的进度为 50%。不过,我想保留图像左侧的圆角。
是否可以动态裁剪 UIImages?
I'm designing a progress bar for an app that essentially is two UIImages - both are the exact same size (long rectangles with rounded corners), except they are colored differently.
The bottom bar is black and the progress bar that will fill over it is grey. Displaying the bottom bar is easy enough. The issue I'm trying to figure out is how to get the grey bar to display only a piece of itself.
For example....
grey : <-------
white: <------------------->
Essentially, I'd like to display only the first half of the grey bar because my progress is at 50%. I'd like to keep the rounded corners at the left of the image though.
Is it possible to dynamically crop UIImages?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
最简单的方法是使用 3 个独立的图像进行创建:2 个带圆角(左和右)的图像,以及一个可轻松调整大小的小图像来显示进度。
是的,您可以动态裁剪图像,但不如进度条所需的那么简单和快速。
The easiest way to do that is to create using 3 separated images: 2 with rounded corners (left and right), and one small easily resizable image to display progress.
And yes, you can crop images dynamically, but not as easy and as quick as need for progress bar.