Android 條紋View、IOS 仿快手直播間Loading條紋加載動畫

ios版本 Github鏈接

Android版本 Github鏈接

仿快手直播界面加載中,頂部的滾動條狀Loading,適用于 視頻加載動畫,直播界面加載動畫?;贑AReplicatorLayer實現(xiàn),占用內(nèi)存極小,非常輕量級

Screenshot 預(yù)覽圖

image

Installation 安裝

先在終端里搜索 pod search StripeAnimationLayer

如果搜索不到1.0.0版本,需要更新你電腦的pod倉庫,以下是更新步驟:

  • pod repo update —verbose 更新你本地電腦的pod倉庫。然后再搜索一次試試看
  • 如果還是搜索不到,執(zhí)行 rm ~/Library/Caches/CocoaPods/search_index.json 。再搜索就OK了
pod 'StripeAnimationLayer'

Example

Swift 調(diào)用方式:

override func viewDidLoad() {
    super.viewDidLoad()
    
    //傾斜layer; y值請一定設(shè)置為0;如果無需傾斜效果,那么width也無需乘以2
    let animationLayer = StripeAnimationLayer(CGRect.init(x: 0, y: 0, width: self.view.frame.size.width * 2, height: self.view.bounds.height / 3), options: StripeLayerOptions())
    self.view.layer.addSublayer(animationLayer);
}

OptionParams 可選參數(shù):

/// 條紋顏色
/// Color of the shapes. Defaults to gray.
open var color = UIColor.lightGray

/// 如果不傾斜,那么gapWidth 和 barWidth相同比較好看,如果傾斜,建議gapWidth是barWidth的兩倍左右
/// Width of the bar
open var barWidth: CGFloat = 8

/// 間距寬度
/// Gap between bars
open var gapWidth: CGFloat = 8

/// 滾動方向
/// Direction
open var moveToRight: Bool = true

/// 滾動速度
/// Speed of the animation
open var speed: Float = 2

/// 傾斜角度, 3/4 = 45 度
/// Rotation of the shapes, 3/4 = 45 degree
open var rotation: CGFloat = CGFloat(Double.pi * 3.5 / 4)

/// 漸變透明度
/// Gradient alpha of the shapes.
open var gradientColors: [CGColor] = [UIColor(red: 0, green: 0, blue: 0, alpha: 0.3).cgColor, UIColor(red: 0, green: 0, blue: 0, alpha: 0).cgColor]

Github鏈接
求Star,后面還有更多好開源項目

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

友情鏈接更多精彩內(nèi)容