我的iOS应用程序的背景颜色不出现在某些设备上
我目前正在开发iOS应用程序。 我将设计调整为不同的Apple设备。 但是,在对iPad Pro第二代测试我的应用程序时,我意识到该设计在几点方面有所不同。 这是我发现的区别:
在代码中,我使用此代码创建自定义弹出窗口:
func createPopup(标题:字符串,消息:字符串,preferredstyle:uialertController.style) - > uialertController { 让警报= uialertController(标题:标题,消息:消息,preferredstyle:preferredstyle) arter.settitlet(字体:uifont.boldsystemfont(ofSize:17),颜色:uicolor(红色:237.0/255,绿色:159.0/255,蓝色:94.0/255,alpha:1)) alter.setMessage(字体:uifont.systemfont(ofSize:13),颜色:uicolor(红色:237.0/255,绿色:159.0/255,蓝色:94.0/255,alpha:1)) 令subview = alert.view.subviews.first!作为uiview 令AlertContentView = subview.subviews.first!作为uiview alertcontentview.backgroundColor = uicolor.black //重要行 AlertContentView.TintColor = Uicolor(红色:237.0/255,绿色:159.0/255,蓝色:94.0/255,Alpha:1) AlertContentView.Layer.CornerRadius = 15; 返回警报
}
这是我所有设备上的普通渲染:
和iPad上的一个:
- 也更改:
正常渲染:
和在iPad上:
- 最后一个旨在闪烁的图像(通过更改Ishidden属性):
闪烁后正常渲染的照片:
和iPad上的:
这三个问题之间有几个共同点。我认为他们都关心背景。
我还在iPhone 12上测试了该应用程序,该应用程序遇到了完全相同的问题。否则,在所有其他设备上都可以很好地工作。 请注意,iPhone 12和iPad属于同一所有者,因此它们连接到同一Apple ID。也许问题与独立于我的应用程序的设置有关,但我无法找出它们是什么(可访问性?)。
感谢您的关注!
I am currently developing an iOS application.
I have adapted my design to the different Apple devices.
However, while testing my app on an iPad Pro 2nd generation, I realized that the design differed on a few points.
Here are the differences I found:
In the code, I create custom pop-ups with this code:
func createPopUp(title: String, message: String, preferredStyle: UIAlertController.Style) -> UIAlertController { let alert = UIAlertController(title: title, message: message, preferredStyle: preferredStyle) alert.setTitlet(font: UIFont.boldSystemFont(ofSize: 17), color: UIColor(red: 237.0/255, green: 159.0/255, blue: 94.0/255, alpha: 1)) alert.setMessage(font: UIFont.systemFont(ofSize: 13), color: UIColor(red: 237.0/255, green: 159.0/255, blue: 94.0/255, alpha: 1)) let subview = alert.view.subviews.first! as UIView let alertContentView = subview.subviews.first! as UIView alertContentView.backgroundColor = UIColor.black // The important line alertContentView.tintColor = UIColor(red: 237.0/255, green: 159.0/255, blue: 94.0/255, alpha: 1) alertContentView.layer.cornerRadius = 15; return alert
}
Here is the normal rendering on all my devices:
And the one on the iPad :
- The color of the tab bar changes too:
The normal rendering :
And on the iPad :
- Finally an image intended to blink (by changing the isHidden property):
Photo of the normal render after blinking :
And on the iPad :
There are several common points between these three problems. I think they all concern the background.
I also tested the app on an iPhone 12 which had exactly the same problems. Otherwise on all other devices all work perfectly.
Note that the iPhone 12 and the iPad belong to the same owner, so they are connected to the same Apple ID. Maybe the problems are related to settings independent of my application but I have not been able to find out what they are (Accessibility?).
Thank you for your attention!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要查找3次的第一个子视图才能更改
backgroundColor
。这是代码。You need to find the first subview for 3 times to change the
backgroundColor
. Here is the code.