[英]Slow loading of an image as a content of CALayer
I have i custom UIView
and i'm setting an image to the contents of a layer. 我有自定义
UIView
并且正在将图像设置为图层的内容。 in the first time the UIViewController
loads it takes 2-3 seconds for the image to appear. 第一次加载
UIViewController
时,图像需要2-3秒的时间才能显示出来。
Why is this happening? 为什么会这样呢? and how can i fix it.
以及我该如何解决。
CODE: 码:
var buttonImage: UIImage = UIImage(named: "circleArrow")!
override func layoutSubviews() {
super.layoutSubviews()
self.setupView()
}
func setupView(){
layer.contents = buttonImage.CGImage
}
Thanks 谢谢
When you set the contents, try calling setNeedsDisplay
on your layer right away. 设置内容时,请尝试立即在图层上调用
setNeedsDisplay
。 If this doesn't work, try the same for your view. 如果这不起作用,请尝试同样的方法进行查看。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.