2012-03-23 6 views
5

Un altro problema con l'animazione su un livello per renderlo scalare e mostra come la crescita dal basso a sinistra, in qualche modo simile alla figura:CALayer animazione scala per dimensione strato partendo dal basso a sinistra in alto a destra

---------------  
|    | 
|---------- | 
|   | | 
|   | | 
|----- | | 
| | | | 
--------------- 

Ho ho provato alcune animazioni ma non sono riuscito a realizzarlo esattamente come voglio io. Si prega di suggerire. Attualmente utilizzando seguente codice in scala:

layer.anchorPoint = CGPointMake(1, 1); 
CABasicAnimation *scale = [CABasicAnimation animationWithKeyPath:@"transform.scale"]; 
[scale setFromValue:[NSNumber numberWithFloat:0.0f]]; 
[scale setToValue:[NSNumber numberWithFloat:1.0f]]; 
[scale setDuration:1.0f]; 
[scale setRemovedOnCompletion:NO]; 
[scale setFillMode:kCAFillModeForwards]; 
+1

appena modificato la mia domanda. – Amit

risposta

6

si dovrebbe impostare un diverso AnchorPoint a acheive tal senso.

layer.anchorPoint = CGPointMake(0.0f, 1.0f); 
1

Tutto questo non funziona per me. I metodi che i frame di fissaggio e punti

- (CGRect) fixRect:(CGRect)rect inRect:(CGRect)container 
{ 
    CGRect frame = rect; 
    frame.origin.y = container.size.height - frame.origin.y - frame.size.height; 
    return frame; 
} 
- (CGPoint) fixPoint:(CGPoint)point fromPoint:(CGSize)containerSize 
{ 
    CGPoint frame = point; 
    frame.y = size.height - frame.y; 
    return frame; 
} 
1

Spero che questo può aiutare:

let frame = pathView.frame 
let anchorPoint = CGPointMake(0, 1) //Set the animation direction 
let position = CGPointMake(frame.origin.x + anchorPoint.x * frame.size.width, frame.origin.y + anchorPoint.y * frame.size.height) 
pathView.layer.anchorPoint = anchorPoint 
pathView.layer.position = position 
UIView.animateWithDuration(0.8){() -> Void in 
    pathView.layer.transform = CATransform3DMakeScale(0.5, 0.5, 1) 
}