我创建了一个社交媒体应用,我想增强用户体验。 为此,我想在加载图像时创建一个动画。 例如,我想产生与我们在 Facebook 上看到的相同的效果
我们并没有真正看到它(仅在个人资料图片上),我什至不知道如何描述它(我不是英语母语者)。就像从左到右的闪光。
我不知道我该怎么做。有人有想法吗?
最佳答案
Facebook 实际上有一个方便的库来帮助解决这个问题:https://github.com/facebook/Shimmer
从 github 页面的 README,它很简单:
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
。祝你好运!
关于ios - swift中的图片加载效果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49802229/