SkeletonView一种优雅的方式,向用户显示正在发生的事情

更新时间:2023-05-15 13:38:45 阅读: 评论:0

英语经典美文SkeletonView⼀种优雅的⽅式,向⽤户显⽰正在发⽣的事情iOS SkeletonView
SkeletonView⼀种优雅的⽅式,向⽤户显⽰正在发⽣的事情,并为他们正在等待的内容做好准备
1.安装
pod "SkeletonView"
2.如何使⽤
2.1在适当的位置导⼊SkeletonView
import SkeletonView
2.2设置视图skeletonables
avatarImageView.isSkeletonable = true
2.3显⽰⾻架
view.showSkeleton()// Solidview.showGradientSkeleton()// Gradientview.showAnimatedSkeleton()// Solid
animatedview.showAnimatedGradientSkeleton()// Gradient animated
2.4更新⾻架(如颜⾊,动画等)
view.updateSkeleton()// Solidview.updateGradientSkeleton()// Gradientview.updateAnimatedSkeleton()// Solid animatedview.updateAnimatedGradientSkeleton()// Gradient animated
2.5隐藏⾻架
好听轻快的英文歌曲view.hideSkeleton()
3.UITableView
tableView.jpg
3.1遵守SkeletonTableViewDataSource协议,并实现协议⽅法
extensionSearchMovieViewController:SkeletonTableViewDataSource{functableView(_tableView:UITableView,numberOfRowsInSec tion ction:Int)->unt}functableView(_tableView:UITableView,cellForRowAt indexPath:IndexPath)-
>UITableViewCell{w]letcell=tableView.dequeueReusableCell(withIdentifier:"SearchMovieCell",for:i ndexPath)as!SearchMovieCellifmodel.vod_pic?.isEmpty==vieImageView.kf.indicatorType=.activity英语辅导
=model.vod_blurbreturncell}funccollectionSkeletonView(_skeletonView:UITableView,cellIdentifierForRowAt indexPath:IndexPath)->ReusableCellIdentifier{return"SearchMovieCell"}}
法语发音规则3.2 设置视图skeletonables
classSearchMovieCell:DiaryBaTableViewCell{/// 图⽚varmovieImageView:UIImageView!/// 标题vartitleLabel:UILabel!/// 详情vardetailsLabel:LCZAlignTopLabel!overridefuncconfig()
{lf.isSkeletonable=truemovieImageView=UIImageView()lf.contentView.addSubview(movieImageView)movieImageView.snp.mak eConstraints{(make)inmake.left.equalToSuperview().offt(Y.equalToSuperview()make.height.equalTo(100)make.w idth.equalTo(80)}Radius=5movieImageView.tMode=.scal eAspectFill
movieImageView.tContentHuggingPriority(.required,for:.horizontal)movieImageView.tContentCompressionResistancePriority (.required,for:.horizontal)movieImageView.isSkeletonable=truetitleLabel=UILabel()lf.contentView.addSubview(titleLabel)titleLabel. snp.makeConstraints{(make)inmake.left.equalTo(movieImageView.snp.right).offt(p.equalTo(p) make.right.equalToSuperview().offt(-
15)}titleLabel.font=LCZBoldFontSize(size:16)titleLabel.tContentHuggingPriority(.required,for:.vertical)titleLabel.tContentCom pressionResistancePriority(.required,for:.="xxxxxxxxx"titleLabel.Alignment= .leftdetailsLabel=LCZAlignTopLabel()lf.contentView.addSubview(detailsLabel)detailsLabel.snp.makeConstraints{(make)inmake.le ft.equalTo(movieImageView.snp.right).offt(p.equalTo(titleLabel.snp.bottom).offt(5)make.right.equalToSuperview().o fft(-
15)make.bottom.equalTo(movieImageView.snp.bottom)}detailsLabel.font=LCZFontSize(size:14)detailsLabel.numberOfLines=0;Color=LCZRgbColor(160,160,160,1)detailsLabel.Alignment=.left}}
3.3 显⽰⾻架
lf.archMovieView.tableView.visibleCells.forEach{$0.showAnimatedGradientSkeleton(usingGradient:SkeletonGradient(baCol or:UIColor.clouds),pLeftBottomRight.slidingAnimation())}
4.UICollectionView
yodo
collectionView.jpg
4.1 遵守SkeletonCollectionViewDataSource协议,并实现协议⽅法
funccollectionSkeletonView(_skeletonView:UICollectionView,cellIdentifierForItemAt indexPath:IndexPath)-
>ReusableCellIdentifier{return"MovieHomeCell"}funccollectionView(_collectionView:UICollectionView,cellForItemAt
indexPath:IndexPath)-
>UICollectionViewCell{letcell=collectionView.dequeueReusableCell(withReuIdentifier:"MovieHomeCell",for:indexPath)as!MovieHo w]ifmodel.vod_pic?.isEmpty==fal{cell.imageView.kf.indicatorType=.activity
cell.imageView.kf.tImage(with:ImageResource(downloadURL:URL(string:model.vod_pic!)!),placeholder:UIImage(named:"zanwutup ian"))}=model.vod_namereturncell}// 显⽰⾻架cell的个数
improves
funccollectionSkeletonView(_skeletonView:UICollectionView,numberOfItemsInSection ction:Int)->Int{return12}
4.2 设置视图skeletonables
classMovieHomeCell:DiaryBaCollectionViewCell{/// 图⽚varimageView=UIImageView()/// 标题
vartitleLabel=UILabel()overridefuncconfig()ui怎么发音
jaheim{lf.Radius=tView.clipsToBounds=tView.addSubview(lf.titleLabel)lf.titleLabel.font=LCZBoldFontSize(size:16)lf.titleLabel.snp.makeConstraints({(make )inmake.bottom.equalToSuperview().offt(-10)make.left.equalToSuperview().offt(10)make.right.equalToSuperview().offt(-10)})Alignment=.centerlf.titleLabel.font=LCZFontSize(size:14)Color=LCZHexadecimalColor(h exadecimal:"#FECE1D")lf.titleLabel.isSkeletonable=="乐淘视
界"lf.contentView.addSubview(lf.imageView)tMode=.scaleAspectFilllf.imageView.clipsToBounds=trues elf.imageView.snp.makeConstraints{(make)p.right.equalToSuperview()make.bottom.equalTo(lf.p).o fft(-10)}lf.imageView.isSkeletonable=true}}
3.3 显⽰⾻架
view.llectionView.prepareSkeleton(completion:
{doneinlf.view.showAnimatedGradientSkeleton(usingGradient:SkeletonGradient(baColor:UIColor.clouds),animation:pLeftBottomRight.slidingAnimation())})ohmygod
4⼈点赞
⽇记本
lumia怎么读

本文发布于:2023-05-15 13:38:45,感谢您对本站的认可!

本文链接:https://www.wtabcd.cn/fanwen/fan/90/109390.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:协议   设置   视图   等待   英文歌曲   准备
相关文章
留言与评论(共有 0 条评论)
   
验证码:
Copyright ©2019-2022 Comsenz Inc.Powered by © 专利检索| 网站地图