1

I created a social media app, and I would like to enhance the UX. For that, I would like to create an animation when an image is loading. I would like to produce the same effect that we can see on Facebook for example

enter image description here

We don't really see it (only on profile image pictures), and I don't even know how I could describe it (I'm not an English native). It's like a flash from the left to the right.

I have no idea about how I could do it. Someone has an idea?

1 Answer 1

3

Facebook actually has a handy library to help with this: https://github.com/facebook/Shimmer

From the github page's README, it's as simple as:

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;

The main thing you'd have to do is change the above code from using a UILabel to whatever UIImageView is being used for your profile images. Good luck!

Sign up to request clarification or add additional context in comments.

5 Comments

Wow that's exactly what I'm looking for! But it seems to be in Objective-C, can I use it with Swift? (Sorry I'm new with swift dev)
Yes you can! Check out this other SO question/answer on that topic: stackoverflow.com/questions/31884507/… -- should be as simple as adding any other Cocoapod as long as you have use_frameworks! in your Podfile
If I have more than 1 Objective-C pod, do I have to write every time I add an Objective-c pod?
No, it's a once per Podfile type of flag :)
The example of adding Shimmer to a label is in Objective-C, does anyone knows how to implement this code for swift 5?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.