Swift-To implement a mixed progress bar by overlaying Uilabel
Effect
Source
Https://github.com/YouXianMing/Swift-Animations
////Mixedcolorprogressviewcontroller.swift//swift-animations////Created by youxianming on 16/8/21.//copyright©2016 year youxianming. All rights reserved.//Import UIKitclassMixedcolorprogressviewcontroller:normaltitleviewcontroller {Privatevar upview:uiview!Privatevar uplabel:uilabel!Privatevar downview:uiview!Privatevar downlabel:uilabel!Privatevar timer:gcdtimer! =Gcdtimer (inQueue:GCDQueue.mainQueue)Overridefunc Setup () {super.setup () Downview= UIView (Frame:cgrectmake (0,0, -, -)) Downview.center= (Contentview?. Middlepoint)!DownView.layer.cornerRadius=2Downview.backgroundcolor=Uicolor.whitecolor () downView.layer.masksToBounds=trueContentview?. Addsubview (downview) Downlabel=UILabel (frame:downView.bounds) Downlabel.font= Uifont.helveticaneuethin (12.0) Downlabel.text="Youxianming-ios Programmer"Downlabel.textcolor=Uicolor.redcolor () downlabel.textalignment= . Center DownView.layer.borderWidth=0.5DownView.layer.borderColor=Uicolor.redcolor (). Cgcolor Downview.addsubview (Downlabel) Upview= UIView (Frame:cgrectmake (0,0, -, -)) Upview.center= (Contentview?. Middlepoint)!UpView.layer.cornerRadius=2Upview.backgroundcolor=Uicolor.redcolor () upView.layer.masksToBounds=trueContentview?. Addsubview (upview) Uplabel=UILabel (frame:upView.bounds) Uplabel.font= Uifont.helveticaneuethin (12.0) Uplabel.text="Youxianming-ios Programmer"Uplabel.textcolor=Uicolor.whitecolor () uplabel.textalignment= . Center Upview.addsubview (Uplabel) weak var wself=Self timer.Event({uiview.animatewithduration (0.5, Delay:0, usingspringwithdamping:3, initialspringvelocity:0, Options:. Curveeaseinout, animations: {wself?. Upview.width = CGFloat (arc4random ()% -)}, Completion:nil)}, Timeintervalwithseconds:1, Delaywithseconds:1) Timer.start ()}}
Swift-To implement a mixed progress bar by overlaying Uilabel