-1

我有一个名为 logoview 的 UIView。

[logoview setCenter:CGPointMake(100,100)];
    [UIView animateWithDuration:4
                          delay:1
                        options: (UIViewAnimationOptionCurveLinear | UIViewAnimationOptionAllowUserInteraction)
                     animations:^{
                         [logoview setCenter:CGPointMake(0, 3232)];


                     }
                     completion:^(BOOL finished) {
                     }];

我正在尝试使用上面的代码对其进行动画处理。它导致对象每次从左上角移动到中心。无论我在动画部分使用什么线......我正在使用情节提要。

我的最终目标是简单地在中心显示徽标。然后像在 Skype 上一样升起徽标,然后 facebook 登录显示登录字段。但是,无论我提出什么价值观

[logoview setCenter:CGPointMake(0, 3232)];

它只是去中心。

我也刚试过:

[UIView animateWithDuration:4
                          delay:1
                        options: (UIViewAnimationOptionCurveLinear | UIViewAnimationOptionAllowUserInteraction)
                     animations:^{
                         [logoview setTransform: CGAffineTransformMakeTranslation(0, -80)];


                     }
                     completion:^(BOOL finished) {
                     }];

这可以提升 logoview,但它也会将其抵消很多......使它偏离中心。

整个.m

//
//  ViewController.m
//  Couple
//
//  Created by Michael Latman on 4/1/13.
//  Copyright (c) 2013 Michael Latman. All rights reserved.
//

#import "ViewController.h"
#import <QuartzCore/QuartzCore.h>

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad
{
    //Rounded corners!
    self.view.layer.cornerRadius = 10;
    self.view.layer.masksToBounds = YES;
    //lol.layer.cornerRadius = 90;
    //lol.layer.masksToBounds = YES;
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    //[logoview setCenter:CGPointMake(100,100)];
    [UIView animateWithDuration:4
                          delay:1
                        options: (UIViewAnimationOptionCurveLinear | UIViewAnimationOptionAllowUserInteraction)
                     animations:^{

                         [logoview setCenter:CGPointMake(0, 1)];


                     }
                     completion:^(BOOL finished) {
                     }];


}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
4

2 回答 2

3

嗯,一个问题是viewDidLoad太快了。你至少要等到viewDidAppear。你的界面还没有真正的大小viewDidLoad。所发生的只是你的视图控制器一个视图;该视图甚至还没有在界面中,更不用说对用户可见了。

于 2013-04-01T21:21:48.293 回答
0

像这样的东西?

[UIView animateWithDuration:4.0 delay:1.0 options:(UIViewAnimationOptionCurveLinear | UIViewAnimationOptionAllowUserInteraction) animations:^{
    [logoview setCenter:CGPointMake(logoview.center.x, logoview.center.y - 80.0)];
} completion:nil];
于 2013-04-01T21:18:53.650 回答