[英]Image loading effect in swift
Facebook實際上有一個方便的庫來幫助解決這個問題: https : //github.com/facebook/Shimmer
從github頁面的自述文件中,它很簡單:
FBShimmeringView *shimmeringView = [[FBShimmeringView alloc]
initWithFrame:self.view.bounds];
[self.view addSubview:shimmeringView];
UILabel *loadingLabel = [[UILabel alloc]
initWithFrame:shimmeringView.bounds];
loadingLabel.textAlignment = NSTextAlignmentCenter;
loadingLabel.text = NSLocalizedString(@"Shimmer", nil);
shimmeringView.contentView = loadingLabel;
// Start shimmering.
shimmeringView.shimmering = YES;
您需要做的主要是將上面的代碼從使用UILabel
更改為用於配置文件圖像的任何UIImageView
。 祝好運!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.