iOS project development Combat-Configure custom animations

Source: Internet
Author: User

Many properties of animation, such as location, transparency, etc., can be used by developers to customize the animation they need. Now let's simply implement how to customize the animation, taking the change of view transparency as an example. Other animation effects can refer to my other two blog "iOS Project development Combat-View animation effect" "iOS project development Combat-implementation of view switch animation."

(1) Also drag a picture into the images.xcassets, and then use a ImageView control in the Main.storyboard to include the image. and bind the control to the code.

(2) Then implement the code below in Viewcontroller, I simply realized the effect of the transparency loop change:

Import Uikitclass Viewcontroller:uiviewcontroller {@IBOutlet weak var image:uiimageview! var Isalpha1:bool = True override func Viewdidload () {super.viewdidload () Self.view.addSubview (i Mage)} override func didreceivememorywarning () {super.didreceivememorywarning ()//Dispose O    F any resources the can be recreated.                     } override func Touchesbegan (touches:set<nsobject>, Withevent event:uievent) {func anim1 () { Image.alpha = 0.5//translucent;} func anim2 () {image . Alpha = 1.0//opaque;} func complete (v:bool) {println (' complete ') is ALPHA1 =!ISALPHA1//cycle changes transparency;} if (ISALPHA1) {Uiview.transitionwithview     (Image, duration:1.0, Options:UIViewAnimationOptions.TransitionNone, ANIMATIONS:ANIM1, Completion:complete)   }else{Uiview.transitionwithview (image, duration:1.0, Options:UIViewAnimationOptions.TransitionNone, animation S:ANIM2, Completion:complete)}}}

(3) The result of the final implementation is as follows:

。



Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

iOS project development Combat-Configure custom animations

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.