0
如何在視圖控制器加載屏幕時啓動操作?查看控制器加載時啓動操作
我已經成功地做我想做與@IBAction
的功能,但我不希望有一個按鈕,按下該行動發生,我希望它開始時的動作頁面加載
有什麼想法?
class ViewController: UIViewController {
var progress: KDCircularProgress!
@IBOutlet weak var Label1: UILabel!
var LabelText = String()
var scorestart = 1.0
var anglepercent = 3.6
override func viewDidLoad() {
super.viewDidLoad()
Label1.text = LabelText
view.backgroundColor = UIColor(white: 0.22, alpha: 1)
progress = KDCircularProgress(frame: CGRect(x: 0, y: 0, width: 200, height: 200))
progress.startAngle = -90
progress.progressThickness = 0.2
progress.trackThickness = 0.3
progress.clockwise = true
progress.gradientRotateSpeed = 10
progress.roundedCorners = false
progress.glowMode = .Forward
progress.glowAmount = 0.9
progress.setColors(UIColor.yellowColor())
progress.center = CGPoint(x: view.center.x, y: view.center.y + 25)
view.addSubview(progress)
}
@IBAction func Animate(sender: AnyObject) {
progress.angle = Double(scorestart * anglepercent)
progress.animateFromAngle(0, toAngle: 270, duration: 2) {
completed in
if completed {
print("animation stopped, completed")
} else {
print("animation stopped, was interrupted")
}
使用相關代碼更新您的問題,其中顯示您嘗試過的內容以及您遇到的問題。 – rmaddy
從'viewDidLoad'調用'@IBAction func Animate ...'。使用'self'作爲'sender'。請不要將函數大寫。 – Grimxn
無論我似乎在做什麼似乎並不工作 self.animate(self)viewDidLoad下不工作 –