2017-05-22 3 views
1

와이파이 신호 펄스를 그려야하고 시작 화면에서 그걸로 애니메이트하고 싶습니다. 나는이 코드로 시도했다. 신호가 아래쪽 단어로 표시되지만 단어를 보여줄 필요가 있습니다.와이파이 신호 펄스를 그리고 애니메이트하는 방법

- (void)viewDidLoad 
{ 
[super viewDidLoad]; 

[self addWavesToView]; 
[self addAnimationsToLayers]; 
} 

- (void)addWavesToView 
{ 
    CGRect rect = CGRectMake(0.0f, 0.0f, 300.0f, 300.0f); 
    UIBezierPath *circlePath = [UIBezierPath 
    bezierPathWithOvalInRect:rect]; 

for (NSInteger i = 0; i < 10; ++i) { 
    CAShapeLayer *waveLayer = [CAShapeLayer layer]; 
    waveLayer.bounds = rect; 
    waveLayer.position = CGPointMake(100, 100); 
    waveLayer.strokeColor = [[UIColor lightGrayColor] CGColor]; 
    waveLayer.fillColor = [[UIColor clearColor] CGColor]; 
    waveLayer.lineWidth = 5.0f; 
    waveLayer.path = circlePath.CGPath; 


    waveLayer.transform = CATransform3DMakeTranslation(0.0f, i*25, 0.0f); 
    waveLayer.strokeStart = 0.25- ((i+1) * 0.01f); 
    waveLayer.strokeEnd = 0.25+((i+1) * 0.01f); 

    [self.view.layer addSublayer:waveLayer]; 
} 
} 

- (void)addAnimationsToLayers 
{ 
NSInteger timeOffset = 10; 
for (CALayer *layer in self.view.layer.sublayers) { 
    CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"strokeColor"]; 
    animation.duration = 10.0f; 

    // Stagger the animations so they don't begin until the 
    // desired time in each 
    animation.timeOffset = timeOffset--; 
    animation.toValue = (id)[[UIColor lightGrayColor] CGColor]; 
    animation.fromValue = (id)[[UIColor darkGrayColor] CGColor]; 

    // Repeat forever 
    animation.repeatCount = HUGE_VALF; 

    // Run it at 10x. You can adjust this to taste. 
    animation.speed = 10; 

    // Add to the layer to start the animation 
    [layer addAnimation:animation forKey:@"strokeColor"]; 
} 
+0

@mhillsman은 이것을 위로 회전시킬 수있는 방법입니다. – Manju

답변

0

"최대 단어에 보여"[우리의 전화 와이파이 신호와 같은] 포인트 TI의 증가에서 시작하면, 그것은 그래서 우리는 viewDidLoad() 기능

의 내부 코드에 의해 180도에 기준 뷰를 회전 할 수 있습니다 더 많은 시간이 걸릴거야
CGFloat degreesOfRotation = 180.0; 
    self.view.transform = CGAffineTransformRotate(self.view.transform, 
             degreesOfRotation * M_PI/180.0); 
+0

감사합니다 :) Working Fine – Manju

관련 문제