1 //uiview.transition2 3 //1. You can set the transition animation from one view to another view4 //uiview.transition (from: < #T # #UIView #>, to: < #T # #UIView #>, Duration: < #T # #TimeInterval #> Options: < #T # #UIViewAnimationOptions #>, completion: < #T # # ((bool)-void)? # # (BOOL)- > void#>)5 6 //2, you can set a view of the animation (such as flipping)7 //uiview.transition (with: < #T # #UIView #>, Duration: < #T # #TimeInterval #>, Options: < #T # # Uiviewanimationoptions#>, animations: < #T # # (() void)? # # (()-void)? # # (), Void#>, completion: < #T # # ((BOOL)-void)? # # ((bool)-void)? # # (BOOL)-void#>)8 9 Import UIKitTen One classViewcontroller:uiviewcontroller { A - Privatevar Iszhengmian:bool =true - the Overridefunc viewdidload () { - super.viewdidload () - } - + @IBAction Func Btnclick (_ Sender:uibutton) { -Iszhengmian =!Iszhengmian + ifiszhengmian{//front, with text, flip from left to right AUiview.transition (With:sender, Duration:0.5, Options:UIViewAnimationOptions.transitionFlipFromLeft, animations: { atSender.settitle ("?", for:. Normal) -}, Completion: {(_)inch - - }) -}Else{//reverse, without text, flip right to left -Uiview.transition (With:sender, Duration:0.5, Options:UIViewAnimationOptions.transitionFlipFromRight, animations: { inSender.settitle (Nil, for:. Normal) -}, Completion: {(_)inch to + }) - } the } *}
Click the button to make the button flip animation left and right