How do you achieve a “clock wipe”/ radial wipe effect in iOS?
Sometimes you’ll see a “clock wipe” animation in use. Something like this:
How would you achieve that effect in iOS?
(Note: This question is a “ringer.” I wanted to share a technique for creating a clock wipe animation, but SO does not have a format for sharing tutorials, so the closest I can come is asking a question and then providing the answer. This is deliberate, and an attempt to share information that others might find useful.)
- Implement custom animation to present modal view from specified view on iPad
- How to stop and reverse a UIView animation?
- How to open UISearchBar like iPhone settings search bar?
- Changing the iOS keyboard animation time
- Draggable UIView Swift 3
- Why calling setNeedsUpdateConstraints isn't needed for constraint changes or animations?
Solutions Collect From Internet About “How do you achieve a “clock wipe”/ radial wipe effect in iOS?”
You’d create CAShapeLayer and install it as a mask on your view’s layer.
You’d then install an arc into the shape layer that spanned a full 360 degrees, and had a radius that was half the center-to-corner distance of your image. You’d give it a line width that was the same as the radius.
Finally, you’d create a CABasicAnimation that animates the strokeEnd property of the shape layer from 0 to 1.0. This would cause the shape to start out empty (image fully masked) and animate the mask as a “pie slice” that got bigger and bigger, until it was the full size of the image.
You can download a sample project on github that I wrote that shows working code for this animation, among other Core Animation techniques:
CA Animation demo on github
- UIProgressView custom track and progress images in iOS 7.1
- Signing and submiting an xcode project to appstore without a mac
- map with photos like Instagram Photo Map
- How can i disable in a Xcode project that a keyboard appears when i touch in a TextField?
- How To Clear Image cache or any cache in AFNetworking?
- Multiple OpenGL views (Cocos2D)
- Interface Builder appears blurry on retina display in Xcode 6.3
- Setting .reuseIdentifier on a UICollectionViewCell
- XCConfig not refreshing until Xcode is restarted
- Tell ScrollView to Scroll after other pan gesture
- UITextView – setting font not working with iOS 6 on XCode 5
- Google Maps for iOS – How can you tell if a marker is within the bounds of the screen?
- SecPKCS12Import does not return any items
- Array filter in Swift3
- Cordova app that doesn't use push notifications: “Missing push notification entitlement”