国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

objective-c - ios 使用約束版面後動(dòng)畫失敗
為情所困
為情所困 2017-05-02 09:34:40
0
1
612

運(yùn)行這段程式碼後,動(dòng)畫效果失敗

#import "ViewController.h"
#import "Masonry.h"
@interface ViewController ()
@property (nonatomic,strong)UIView *a;
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    UIView *a = [[UIView alloc] init];
    a.backgroundColor = [UIColor redColor];
    [self.view addSubview:a];
    self.a = a;
    
    [a mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.view);
        make.right.equalTo(self.view);
        make.bottom.equalTo(self.view.mas_bottom);
        make.height.equalTo(@100);
    }];
    
    
    UIButton *b = [[UIButton alloc] initWithFrame:CGRectMake(20, 20, 200 , 200)];
    b.backgroundColor = [UIColor greenColor];
    [self.view addSubview:b];
    [b addTarget:self action:@selector(ad) forControlEvents:UIControlEventTouchUpInside];
}

-(void)ad{
    [UIView animateWithDuration:2 delay:1 options:UIViewAnimationOptionCurveEaseIn animations:^{
        self.a.center = CGPointMake(self.a.center.x, self.a.center.y - 200);
    } completion:^(BOOL finished) {
        NSLog(@"11111 %@",self.a);

        [self.view addSubview:[[UIView alloc] init]];
          NSLog(@"12222222 %@",self.a);
    }];
}

點(diǎn)擊按鈕,動(dòng)畫效果會(huì)在最後恢復(fù)到最初始的位置,是否有人能夠簡(jiǎn)單解答一下,為什麼[self.view addSubview:[[UIView alloc] init]]; 會(huì)造成這個(gè)問(wèn)題

為情所困
為情所困

全部回覆(1)
黃舟

當(dāng)你用autolayout佈局後,對(duì)應(yīng)的view如果需要做動(dòng)畫,也要改變佈局,而不是frame。

最新下載
更多>
網(wǎng)站特效
網(wǎng)站源碼
網(wǎng)站素材
前端模板