Implementation of animation effect using AutoLayout in StoryBoard

Source: Internet
Author: User

The use of AutoLayout layout, as a beginner will be all of us will think again and animation missed, no longer to achieve the effect of animation.

But, I want to say, little friends, your ideas are wrong.

In the case of using AutoLayout, we can also achieve the effect of animation.

View in storyboard, the basic layout is achieved by constraints constraints, by changing the control's

Transform properties to achieve basic animation effects.

The view add constraints is actually a restriction on the coordinate position of the bounds in the view, and the animation effect can be achieved by modifying the relative coordinates on the bounds in the views. (modifies the relative position of the bounds and does not affect the coordinates of the frame of the child view in view).

Test code:

Class Viewcontroller:uiviewcontroller {


@IBOutlet weak var passwordlabel:uilabel!

@IBOutlet weak var phonelabel:uilabel!

@IBOutlet weak var toplabel:uilabel!

Override Func Viewdidload () {

Super.viewdidload ()

Toplabel.transform = cgaffinetransformmaketranslation (0,-200)

Passwordlabel.transform = cgaffinetransformmaketranslation (-200,-200)

Phonelabel.transform = cgaffinetransformmaketranslation (-200, 0)

Do no additional setup after loading the view, typically from a nib.

}

Override func Viewdidappear (Animated:bool) {

Uiview.animatewithduration (0.5) {

Self.topLabel.transform = cgaffinetransformidentity

Self.phoneLabel.transform = cgaffinetransformidentity

Self.passwordLabel.transform = cgaffinetransformidentity

}

}




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.