Swift view additions and levels changes and basic animations

Source: Internet
Author: User
Tags closure

//in general, we add a view to the parent view by        /*Let v1 = UIView (Frame:cgrectmake (100,200,30,50)) Self.view.addSubview (v1)//Self . View represents the view of the controller*/The view added in this way is that the more you add back, the more we have these methods in the top level:1.0Insertsubview (View:uiview, Atindex index:int)//Places an attempt to place the view in the sub-view array with the subscript index    2.0Insertsubview (View:uiview, Belowsubview Siblingsubview:uiview)//will try to place the view below the Siblingsubview view    3.0Insertsubview (View:uiview, Abovesubview Siblingsubview:uiview)//will try to place the view above the Siblingsubview view//2.0 ways to change the hierarchy of sub-views    1.0Bringsubviewtofront (View:uiview)//move the view to the top of all the child views    2.0Sendsubviewtoback (View:uiview)//move the view to the bottom of all child views    3.0Exchangesubviewatindex (Index1:int, Withesubviewatindex index2:int)//Swap locations for sub-views with subscript index1 and sub-views labeled Index2//3.0 UIView Basic Animations We can change the properties of the view include: 1 position (x and Y) 2.0 size (width andHeight3.0Color (solid color)4.0Transparency1.0 /** * Only one duration and the final state of the animation * Uiview.animatewithduration (< #T # #duration: nstimeinterval# #NSTime Interval#>, animations: < #T # # (), void#>)*/        2.0  /** Duration: The time to perform the animation animations: The final state of the animation the third parameter: After the animation is finished, you need to do A series of Action Uiview.animatewithduration (< #T # #duration: nstimeinterval# #NSTimeInterval #> anima tions: < #T # # () Void#>, Completion: < #T # # ((bool)--void)? # # (BOOL), void#> )              */        3.0Uiview.animatewithduration (< #T # #duration: nstimeinterval# #NSTimeInterval #>, delay: < #T # #NSTimeInterval # , Options: < #T # #UIViewAnimationOptions #>, animations: < #T # # (), Void#>, completion: < #T # # ((Bool , void)? # # ((bool), void)? # # (BOOL)-void#>Duration: The entire animation duration, the larger the value, the slower the animation is: delay, that is, after waiting for dealy seconds to start the animation options: Related animation Run parameters General Animation property settings (you can select multiple settings at the same time)                Uiviewanimationoptionlayoutsubviews: Ensure that the child view follows the motion during the animation.                Uiviewanimationoptionallowuserinteraction: Allows user interaction during animation.                Uiviewanimationoptionbeginfromcurrentstate: All views start running from the current state.                Uiviewanimationoptionrepeat: Run the animation repeatedly.                Uiviewanimationoptionautoreverse: The animation is still animated back to the initial point after it runs to the end point.                Uiviewanimationoptionoverrideinheritedduration: Ignores nested animation time settings.                Uiviewanimationoptionoverrideinheritedcurve: Ignores nested animation speed settings.                Uiviewanimationoptionallowanimatedcontent: Redraw The View during animation (note only for transition animations). Uiviewanimationoptionshowhidetransitionviews: Hide the old view directly, display the new view when the view toggles, instead of removing the old view from the parent view (only for transition animations) uiviewanimationopt                Ionoverrideinheritedoptions: Does not inherit parent animation settings or animation types. 2. Animation speed control (where you can choose a setting) Uiviewanimationoptioncurveeaseinout: The animation starts slowly, then accelerates gradually.                Uiviewanimationoptioncurveeasein: Animation gradually slows down.                Uiviewanimationoptioncurveeaseout: Animation gradually accelerates.                Uiviewanimationoptioncurvelinear: The animation is executed at a constant speed, default value. 3. Transition type (applies only to transition animation settings, from which you can choose one to set, basic animations, keyframe animations do not need to be set) Uiviewanimationoptiontransitionnone: No transition animation effect.                Uiviewanimationoptiontransitionflipfromleft: Flips the effect from the left.                Uiviewanimationoptiontransitionflipfromright: Flips the effect from the right.                Uiviewanimationoptiontransitioncurlup: Animated transition effect that pages back.                Uiviewanimationoptiontransitioncurldown: Animated transition effect that pages forward.                Uiviewanimationoptiontransitioncrossdissolve: The old view dissolve disappears to show the effect of the next new view.                Uiviewanimationoptiontransitionflipfromtop: Flips the effect from above. Uiviewanimationoptiontransitionflipfrombottom: Flips the effect from the bottom. Animations: This is a closure, and in this closure, all parameters are the final state of the animation completion: This is also a closure, which means that the animation will be executed after the entire animation has been completed. Of course, these methods can be nested using the

Swift view additions and levels changes and basic animations

Related Article

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.