iOS 5 和 interpolatedColorAtLocation。获取特定位置处的渐变颜色
如何在 iOS 5 中获取特定位置的渐变颜色? 我有一个垂直条,其渐变从红色到绿色,左侧是一个三角形,显示条中的位置。如何用该位置的条形颜色填充三角形? 我认为在 Mac OS X 中它是“interpolatedColorAtLocation”,但是 iOS 5 呢?
谢谢你的帮助。
How can I get the color in a gradient at a specific position in iOS 5?
I have a vertical bar with a gradient from red to green and on the left side is a triangle showing the position in the bar. How can I fill the triangle with the color of the bar at that position?
I think in Mac OS X it's "interpolatedColorAtLocation" but how about iOS 5?
Thank you for help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
更多
发布评论
评论(1)
iOS 中没有这方面的 API。您必须自己进行渐变插值,或者将渐变绘制到 CGBitmapContext 中,然后在位图的原始数据中查找像素值。
There's no API for this in iOS. You'll have to do the gradient interpolation yourself, or draw your gradient into a
CGBitmapContext
and then find the pixel value in the bitmap's raw data.