Swift-To implement a mixed progress bar by overlaying Uilabel

Source: Internet
Author: User

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

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.