Swift and swiftcode

Source: Internet
Author: User

Swift and swiftcode

Swift-RotateView

 

Effect

 

Source code

Https://github.com/YouXianMing/Swift-Animations

/// RotateView. swift // Swift-Animations // Created by YouXianMing on 16/8/14. // Copyright©2016 YouXianMing. all rights reserved. // import UIKit // MARK: Public class: RotateViewclass RotateView: UIView {// MARK: Properties. var rotateDuration: NSTimeInterval = 0.25 // MARK: Animation method. func changeToUpAnimated (animated: Bool) {UIView. animateWithDuration (animated = true? Self. rotateDuration: 0.0) {self. transform = self. defaultTransform} func changeToLeftAnimated (animated: Bool) {UIView. animateWithDuration (animated = true? Self. rotateDuration: 0.0) {self. transform = CGAffineTransformRotate (self. defaultTransform, CGFloat (-M_PI_2)} func changeToRightAnimated (animated: Bool) {UIView. animateWithDuration (animated = true? Self. rotateDuration: 0.0) {self. transform = CGAffineTransformRotate (self. defaultTransform, CGFloat (M_PI_2)} func changeToDownAnimated (animated: Bool) {UIView. animateWithDuration (animated = true? Self. rotateDuration: 0.0) {self. transform = CGAffineTransformRotate (self. defaultTransform, CGFloat (M_PI)} // MARK: Private value & func & system method. private var defaultTransform: CGAffineTransform! Override init (frame: CGRect) {super. init (frame: frame) defaultTransform = self. transform} required init? (Coder aDecoder: NSCoder) {fatalError ("init (coder :) has not been implemented ")}}

 

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.