Jak animować / obracać UIView o 90 stopni w prawym górnym rogu?

Szukałem przez wiele godzin próbując znaleźć sposób, aby animować / obracać UIView o 90 stopni od prawego górnego rogu.

Efekt powinien działać prawie jak drzwi wahadłowe od góry ekranu.

Mam nadzieję, że ktoś pomoże!

Author: Andrew, 2010-11-01

3 answers

Więc zaraz po naciśnięciu enter nagle połączyłem dwa i dwa i pomyślałem, że próbka metronomu działa jak wahadłowe drzwi i to doprowadziło mnie do kilku innych możliwości.

Oto moje rozwiązanie:

- (void)viewDidLoad {
    [super viewDidLoad];

    // Set the anchor point and center so the view swings from the upper right
    swingView.layer.anchorPoint = CGPointMake(1.0, 0.0);
    swingView.center = CGPointMake(CGRectGetWidth(self.view.bounds), 0.0);

    // Rotate 90 degrees to hide it off screen
    CGAffineTransform rotationTransform = CGAffineTransformIdentity;
    rotationTransform = CGAffineTransformRotate(rotationTransform, DegreesToRadians(90));
    swingView.transform = rotationTransform;
}

...

- (void)animateSwing {

    CGAffineTransform swingTransform = CGAffineTransformIdentity;
    swingTransform = CGAffineTransformRotate(swingTransform, DegreesToRadians(0));

    [UIView beginAnimations:@"swing" context:swingView];
    [UIView setAnimationDuration:0.25];

    swingView.transform = swingTransform;

    [UIView commitAnimations];
}

Mam nadzieję, że to pomoże komuś innemu!

 25
Author: dandax,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2010-11-02 13:02:34

Należy spróbować ustawić punkt kontrolny warstwy na (0,1), a następnie animować warstwę.

 0
Author: tadejsv,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2010-11-01 19:59:38

Powinieneś wypróbować ten kod:

-(void)doRotationView{
[UIView beginAnimations:@"flipping view" context:nil];  
    [UIView setAnimationDuration:1];    
    [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];   
    [UIView setAnimationTransition: UIViewAnimationTransitionFlipFromLeft    
                           forView:self cache:YES];
    if (flagFront == 1) {
        flagFront =0;
        [self.viewSecond setHidden:NO];
        [self.viewFirst setHidden:YES];
    }
    else{
        flagFront =1;
        [self.viewSecond setHidden:YES];
        [self.viewFirst setHidden:NO];        
    }
    [UIView commitAnimations];

}

 -4
Author: nghiamas,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2012-10-11 00:20:50