[Swift]Swift #5 animateWithDuration
Swift #5 animateWithDuration
@IBOutlet weak var mainLabel: UILabel! func initUI(){ var message:String = getMessage(message:"いあうえ",message2:"390u8") println(message) message = getMessage(message2:"むぎちゃ") println(message) UIView.animateWithDuration( 2.0, delay: 1.0, usingSpringWithDamping: 1.0, initialSpringVelocity: 0.0, options: UIViewAnimationOptions.CurveEaseInOut, animations:{()in self.mainLabel.frame = CGRectMake(100.0, 300.0, self.mainLabel.frame.size.width, self.mainLabel.frame.size.height) }, completion:{(finished)in println("finished:\(finished)") }) } func getMessage(var message:String="ABC",var message2:String="MBNRKF")->String{ return "\(message) \(message2)" } override func viewDidLoad() { super.viewDidLoad() initUI() }
出力結果
いあうえ 390u8 ABC むぎちゃ finished:true