how to animation a label on circular path in iOS?
I am stuck at animating the uiLabel in my view.
Actually I just want to animate my label/Text on a circular path. I have searched a lot over internet but couldn’t find any good tutorial or example that is doing something like my problem. I have done CAShapeLayer (circle) increasing from 0 to its maximum value….
Similarly I want that my label/text start moving from initial point in circular path and come back to its initial point after completing one circle.
Hope I have explained my problem quite precisely … still if there is anything missing or non-understandable. please ask me.
Thanks in anticipation.
- Trying to delay CABasicAnimation position and opacity of layer by 3 seconds but
- How do I simultaneously animate a UIImageView's image and the UIImageView itself?
- replacing CALayer and CABasicAnimation with SKScene and SKActions
- Animation of stroke of circle segment ends in complete stroke
- Animating CALayer background color and update model value
- CABasicAnimation rotate returns to original position
Solutions Collect From Internet About “how to animation a label on circular path in iOS?”
Hi iOmi i just google it and i found Best Question similar like your This
Bellow it’s a jin’s answer Hope its helps you
CAShapeLayer* circle = [[CAShapeLayer alloc] init]; CGMutablePathRef path = CGPathCreateMutable(); CGRect textRect = CGRectMake(self.view.bounds.size.width/4, (self.view.bounds.size.height-self.view.bounds.size.width/2)/2, self.view.bounds.size.width/2, self.bounds.size.width/2); float midX = CGRectGetMidX(textRect); float midY = CGRectGetMidY(textRect); CGAffineTransform t = CGAffineTransformConcat( CGAffineTransformConcat( CGAffineTransformMakeTranslation(-midX, -midY), CGAffineTransformMakeRotation(-1.57079633/0.99)), CGAffineTransformMakeTranslation(midX, midY)); CGPathAddEllipseInRect(path, &t, textRect); circle.path = path; circle.frame = self.bounds; circle.fillColor = [UIColor clearColor].CGColor; circle.strokeColor = [UIColor blackColor].CGColor; circle.lineWidth = 60.0f; [self.layer addSublayer:circle]; CABasicAnimation* animation = [CABasicAnimation animationWithKeyPath:@"strokeEnd"]; animation.duration = 15.0f; animation.fromValue = [NSNumber numberWithFloat:0.0f]; animation.toValue = [NSNumber numberWithFloat:1.0f]; animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear]; [circle addAnimation:animation forKey:@"strokeEnd"]; [circle release]; UILabel* label = [[UILabel alloc] init]; label.text = @"Test Text"; label.font = [UIFont systemFontOfSize:20.0f]; label.center = CGPathGetCurrentPoint(path); label.transform = CGAffineTransformMakeRotation(1.57079633); [label sizeToFit]; [self.layer addSublayer:label.layer]; CAKeyframeAnimation* textAnimation = [CAKeyframeAnimation animationWithKeyPath:@"position"]; textAnimation.duration = 15.0f; textAnimation.path = path; textAnimation.rotationMode = kCAAnimationRotateAuto; textAnimation.calculationMode = kCAAnimationCubicPaced; textAnimation.removedOnCompletion = NO; [label.layer addAnimation:textAnimation forKey:@"position"];
i just create a demo of it screen shot is:-
HERE IS DEMO LINK
- libsqlite3.dylib and libz.dylib missing in Xcode 7. How do I use Parse?
- NSString instance reports its class as NSCFString
- How to remove a SwiftyJSON element?
- Does PhoneGap / Apache Cordova propose an API for encrypted SQLite database
- Upload Multiple Images to Server IOS
- Why does my time UILabels skip 2 seconds when it resumes play from a pause state?
- How to programmatically silence the ringer or change the ringer tone on iOS5
- How can i fix my scrollView dynamically when i have more than one textViews in it?
- What are the differences between segues: “show”, “show detail”, “present modally”, “present as popover”?
- iOS table view lag issue, i'm using dispatch and save cache
- Core Data with WatchKit and iOS App
- ios settings screen user interface
- @import “Unexpected '@' in program”
- How to fetch email id from JSON file in firebase using swift
- Combine two iOS apps into one