简体   繁体   English

如何根据Swift中的背景图像调整文本Label颜色

[英]How to Adjust the Text Label Color According to the Background Image in Swift

I am using a lot of different background images in my project and I wanted to know how can I adjust the UITextLabel colour according to the Background Image View on my View Controller?我在我的项目中使用了很多不同的背景图像,我想知道如何根据我的视图 Controller 上的背景图像视图调整 UITextLabel 颜色? ie if the background is dark the text will become.white whereas if the background is light the text will become.black.即,如果背景较暗,则文本将变为.white,而如果背景较浅,则文本将变为.black。 Any help will be highly appreciated:)任何帮助将不胜感激:)

If you are okay with using third-party libraries, what I would suggest is to use https://cocoapods.org/pods/ChameleonFramework to get access to its function如果您可以使用第三方库,我建议您使用https://cocoapods.org/pods/ChameleonFramework来访问其 function

ContrastColorOf(backgroundColor: UIColor, returnFlat: Bool)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM