• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Swift - 通过叠加UILabel来实现混合的进度条

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

Swift - 通过叠加UILabel来实现混合的进度条

 

效果

 

源码

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

//
//  MixedColorProgressViewController.swift
//  Swift-Animations
//
//  Created by YouXianMing on 16/8/21.
//  Copyright © 2016年 YouXianMing. All rights reserved.
//

import UIKit

class MixedColorProgressViewController: NormalTitleViewController {
    
    private var upView    : UIView!
    private var upLabel   : UILabel!
    private var downView  : UIView!
    private var downLabel : UILabel!
    private var timer     : GCDTimer! = GCDTimer(inQueue: GCDQueue.mainQueue)
    
    override func setup() {
        
        super.setup()
        
        downView                     = UIView(frame: CGRectMake(0, 0, 220, 17))
        downView.center              = (contentView?.middlePoint)!
        downView.layer.cornerRadius  = 2
        downView.backgroundColor     = UIColor.whiteColor()
        downView.layer.masksToBounds = true
        contentView?.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.5
        downView.layer.borderColor = UIColor.redColor().CGColor
        downView.addSubview(downLabel)
        
        upView                     = UIView(frame: CGRectMake(0, 0, 220, 17))
        upView.center              = (contentView?.middlePoint)!
        upView.layer.cornerRadius  = 2
        upView.backgroundColor     = UIColor.redColor()
        upView.layer.masksToBounds = true
        contentView?.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() % 220)
                
                }, completion: nil)
            
            }, timeIntervalWithSeconds: 1, delayWithSeconds: 1)
        timer.start()
    }
}

 


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
OptimizingCollections(Swift4)发布时间:2022-07-13
下一篇:
OpenStackObjectStorageDeveloperGuide/Swift官方API文档--翻译(五)发布时间:2022-07-13
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap