【发布时间】:2015-04-03 10:00:14
【问题描述】:
我使用 swift 和 UIKit 为简单的游戏创建图形,使用间隔 = 0.03。大约是 30FPS
class CView: UIView {
let img = UIImage(named: "background.png")
func initalize(){
var timer = NSTimer.scheduledTimerWithTimeInterval(0.03, target: self, selector: Selector("update"), userInfo: nil, repeats: true)
}
func update(){
setNeedsDisplay();
}
override func drawRect(rect: CGRect){
img?.drawAtPoint(CGPoint(x: 0, y: 0))
}
}
在 ViewController 的课程中,我对所有设备都使用全屏比例
let mainview = CView()
mainview.initalize()
var rect = UIScreen.mainScreen().bounds
var scaleX = rect.width / 480;
var scaleY = rect.height / 800;
mainview.transform = CGAffineTransformScale(CGAffineTransformIdentity, scaleX, scaleY);
view = mainview
在 30FPS 的模拟器上运行良好,但在真实设备(iPhone 4S、Iphone 4)、10-14FPS(Iphone 5,5s)上只有 5-8 FPS。那么,如何在真机上获得更好的性能。 我只画了一个图像,所以我想画更多性能最好的图像。有什么帮助吗?
【问题讨论】:
标签: ios performance swift uikit core-graphics