Swift and swiftcode
Swift-animation effects of multiple masks
Effect
Source code
Https://github.com/YouXianMing/Swift-Animations
/// TranformFadeView. swift // Swift-Animations // Created by YouXianMing on 16/8/20. // Copyright©2016 YouXianMing. all rights reserved. // import UIKitenum TranformFadeViewAnimatedType: Int {case Fade, Show} // MARK: TranformFadeViewclass TranformFadeView: UIView {// MARK: Convenience init. convenience init (frame: CGRect, verticalCount: Int, horizontalCount: Int, fadeDuradtion: NSTimeInterval, animationGapDuration: NSTimeInterval) {self. init (frame: frame) self. verticalCount = verticalCou Nt self. horizontalCount = horizontalCount self. fadeDuradtion = fadeDuradtion self. animationGapDuration = animationGapDuration self. makeconfigshorttive ()} // MARK: Properies & funcs. /// The content imageView's image. var image: UIImage? {Get {return imageView. image} set (newVal) {imageView. image = newVal }}// The content imageView's contentMode. var imageContentMode: UIViewContentMode {get {return imageView. contentMode} set (newVal) {imageView. contentMode = newVal }}// Vertical direction view's count. var verticalCount: Int! /// Horizontal direction view's count. var horizontalCount: Int! /// One of the maskView's animation duration, default is 1.0 var fadeDuradtion: NSTimeInterval! = 1 // The animation duration two subViews from allMaskView, default is 0.2 var animationGapDuration: NSTimeInterval! = 0.2/** Make the config into tive. */func makeconfiginto tive () {if verticalCount <1 | horizontalCount <1 {return;} if allMaskView! = Nil {allMaskView. removeFromSuperview ()} countNumArray. removeAll () allMaskView = UIView (frame: bounds) maskView = allMaskView let height = bounds. size. height let width = bounds. size. width let maskViewHeight = height/CGFloat (verticalCount) let maskViewWidth = width/CGFloat (horizontalCount) var count: Int = 0 for horizontal in 0 ..