如何根据背景图像颜色更改UILabel文本颜色?

时间:2013-11-16 13:10:16

标签: ios iphone objective-c uiimageview uilabel

我想根据背景图片颜色更改标签文字颜色。背景图片位于UIScrollView上,UILabel位于其上方。滚动滚动视图时,应根据背景图像颜色更改标签颜色。

基本上,如果标签位于图像的黄色部分,它会是黑色的,如果它位于图像的蓝色部分,则会是白色的。

见下图:

if the label was on the yellow part of the image, it would be black, and if it was on the blue part of the image, it would be white

提前致谢...

1 个答案:

答案 0 :(得分:1)

首先创建一个UIView,假设它是hiddenView,其大小与contentsize的{​​{1}}相同,并设置您scorllview的背景颜色您设置image的背景,但不需要将此视图添加到任何位置。

实施scrollview方法

scrollViewDidScroll

试试这个,希望它能满足你的要求。