简体   繁体   English

如何让绿色像 iPhone 锁屏上的充电电池一样显示?

[英]How to get a green to show up like the charging battery on the iPhone lock screen?

I am trying to get a color to show up on screen just like the charging battery (shown here):我试图让一种颜色显示在屏幕上,就像充电电池一样(如图所示):充电电池

After looking at the Apple Documentation on UIColor here , I have attempted using both colorWithHue:saturation:brightness:aplha: and colorWithRed:green:blue:alpha: to get a color to show up like that.看着对苹果文档后UIColor 这里,我一直在使用这两种尝试colorWithHue:saturation:brightness:aplha:colorWithRed:green:blue:alpha:为了获得彩色显示得那样。

For example when I use colorWithHue:.3 saturation:.84 brightness:1 alpha:.5 on a black background, it renders a color like this:例如,当我在黑色背景上使用colorWithHue:.3 saturation:.84 brightness:1 alpha:.5时,它会呈现如下颜色:

myGreen 与 colorWithHue:saturation:brightness:alpha:

or the colorWithRed:0 green:1 blue:0 alpha:.5 on a black background shows up like this:或者黑色背景上的colorWithRed:0 green:1 blue:0 alpha:.5显示如下:

myGreen 与 colorWithRed:green:blue:alpha:

It doesn't have that translucent or glossy look to it.它没有那种半透明或有光泽的外观。

Is there a better method to use?有没有更好的使用方法? Or do I just not have the values right?或者我只是没有正确的价值观? (I have tried many combinations) (我试过很多组合)

UIColor represents only one colour with an opacity value (if you've stated one). UIColor仅表示一种具有不透明度值的颜色(如果您已经说明了一种颜色)。 In your case you might want to either use images, or override the drawRect method in a custom UIView class (Core Graphics).在您的情况下,您可能想要使用图像,或覆盖自定义UIView类(核心图形)中的drawRect方法。 Take a look here for a brief introduction to the latter.这里对后者的简要介绍。

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

相关问题 我的应用充电时如何防止iPhone锁定 - How to prevent iPhone to lock when my app is charging 当状态栏也显示时,如何使iOS 7状态栏中的绿色电池图标(手机正在充电)褪色? - How do I make the green battery icon (when phone is charging) in the status bar of iOS 7 fade when the status bar does as well? 斯威夫特 - 如果电池即使在100%充电也能获得 - Swift - Get if battery is charging even at 100% 暂停应用程序后,如何在iPhone上获取屏幕锁定/解锁事件? - How to get screen lock/unlock events on the iPhone when app is suspended? 用秒显示iPhone锁屏(自用) - Show iPhone lock screen with seconds (own usage) 如何在一段时间内将Iphone锁定到应用程序的特定屏幕(以编程方式像儿童模式一样)? - How to lock Iphone to a specific screen of app for some time, same like kids mode programmatically? 如何在锁定屏幕上显示与左下角相机相同的 iPhone 应用程序图标 - How to show iphone app icon on lock screen same as camera on bottom left 如何在iPhone的人像/风景中锁定屏幕? - How to lock screen in portrait/landscape in iPhone? 如何在iPhone或iPad上为锁屏设置墙纸 - How to set wallpaper for lock screen in iPhone or iPad 如何在iPhone中设计Android模式锁屏 - how to design Android Pattern Lock Screen in iphone
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM