gpt4 book ai didi

ios - self.button.layer.backgroundColor 和 self.button.backgroundColor 有什么区别?

转载 作者:行者123 更新时间:2023-11-28 12:52:50 27 4
gpt4 key购买 nike

这两行 Swift 代码在功能上有区别吗?

self.button.layer.backgroundColor = UIColor.whiteColor().CGColor

self.button.backgroundColor = UIColor.whiteColor()

?

最佳答案

根据 John Blanco's blog :

Every UIView comes packaged with a CALayer knows as the “backing layer” or “underlying layer.” Many of the methods you call on UIView simply delegate to the layer. When you change a view’s frame, it’s simply changing the layer’s frame. If you change the alpha, it changes the layer’s alpha…and so on with background colors, transformations and more. And while you can maintain a hierarchy of UIViews each representing parents and children of one another, you can do the same with CALayer

关于ios - self.button.layer.backgroundColor 和 self.button.backgroundColor 有什么区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35925385/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com