当前位置: 首页 > 工具软件 > PureLayout > 使用案例 >

PureLayout 加 动画

章锦
2023-12-01
@interface ViewController () 
@property(nonatomic, strong)    NSLayoutConstraint *topConstraint;
@end

@implementation ViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
    
    UIView *view = [[UIView alloc] init];
    view.backgroundColor = [UIColor redColor];
    [self.view addSubview:view];
    
    [view autoPinEdge:ALEdgeLeft toEdge:ALEdgeLeft ofView:self.view withOffset:40];
    NSLayoutConstraint *topConstraint = [view autoPinEdge:ALEdgeTop toEdge:ALEdgeTop ofView:self.view withOffset:40];
    self.topConstraint = topConstraint;
    [view autoSetDimensionsToSize:CGSizeMake(100, 100)];

    
    
}

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    
    [UIView animateWithDuration:1 animations:^{
        
        self.topConstraint.constant = 100;
        [self.view layoutIfNeeded];
        
    }];
}

 类似资料: