![](/img/trans.png)
[英]UIView setNeedsDisplay calling the CALayer's setNeedsDisplay?
[英]UIView setNeedsDisplay Has No Effect?
我有一個UIView派生的視圖,該視圖僅繪制一次,並且從未更新 。
調用[self setNeedsDisplay]
無效。 是什么原因造成的?
繪圖代碼是否在其中都沒關系
drawRect:
或 drawLayer:inContext:
定義了一個空的drawRect()) 如果未定義drawLayer:inContext,則調用drawRect。 但是只有一次(在布局期間)。
- (void)drawLayer:(CALayer*)layer inContext:(CGContextRef)ctx {
// drawing occurs, but just once (during view layout)
}
`- (void)drawRect:(CGRect) rect {
// empty -- never called
}
我嘗試過的一小部分:
因此,可以將其標記為已回答:確保在主線程上調用UIKit方法。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.