1
我正在處理的應用程序要求我將圖像繪製到UIView
。這些圖像很大(有些是1024x768),我想確保我的繪圖代碼不是次優的。我在我的UIView
drawRect
方法是這樣的:這是將大圖像繪製到UIView的最佳方式嗎?
- (void)drawRect:(CGRect)rect {
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextClearRect(context, rect);
CGAffineTransform flipVertical = CGAffineTransformMake(1, 0, 0, -1, 0, 550);
CGContextConcatCTM(context, flipVertical);
CGImageRef shadowImage = [[UIImage imageNamed:@"someimage.png"] CGImage];
CGContextDrawImage(context, CGRectMake(162, -174, 700, 700), shadowImage);
CGContextConcatCTM(context, flipVertical);
}
這裏有過做其它繪圖,但我只是想確保圖像繪製代碼不會導致問題,我沒有忽視了調用一個重要的方法或者錯誤地實現了這一點。
鏈接不起作用 – 2012-12-19 14:47:45
@PooLaS固定 - 歡呼! – Codebeef 2012-12-20 11:55:12
所以結論是使用'[UIImage imageWithContentsOfFile:路徑];'而不是'[UIImage imageNamed:@「someimage.png」];'line :) – 2012-12-20 12:02:52