美文网首页
UIView的常见属性

UIView的常见属性

作者: GrayWolf | 来源:发表于2016-04-25 22:35 被阅读0次
    //  ViewController.m
    //  spin
    //
    //  Created by 袁跃 on 16/4/25.
    //  Copyright © 2016年 iflytek. All rights reserved.
    //
    
    #import "ViewController.h"
    
    @interface ViewController ()
    @property (weak, nonatomic) IBOutlet UIButton *btnButton;
    - (IBAction)move:(id)sender;
    - (IBAction)spin:(id)sender;
    - (IBAction)scale:(id)sender;
    - (IBAction)back:(id)sender;
    - (IBAction)change:(id)sender;
    
    @end
    
    @implementation ViewController
    
    - (void)viewDidLoad {
        [super viewDidLoad];
        // Do any additional setup after loading the view, typically
     from a nib.
    }
    
    - (void)didReceiveMemoryWarning {
        [super didReceiveMemoryWarning];
        // Dispose of any resources that can be recreated.
    }
    
    - (IBAction)move:(id)sender {
        
        self.btnButton.transform = CGAffineTransformTranslate(self.btnButton.transform, 0, 50);
    }
    
    - (IBAction)spin:(id)sender {
        
        [UIView animateWithDuration:3 animations:^{
            self.btnButton.transform = CGAffineTransformTranslate(self.btnButton.transform, 0, 50);
            self.btnButton.transform = CGAffineTransformScale(self.btnButton.transform, 2, 2);
            self.btnButton.transform = CGAffineTransformRotate(self.btnButton.transform, M_PI_4);
            
        }];
    }
    
    - (IBAction)scale:(id)sender {
        
        self.btnButton.transform = CGAffineTransformScale(self.btnButton.transform, 0.5, 0.5);
    }
    
    - (IBAction)back:(id)sender {
        
        self.btnButton.transform = CGAffineTransformIdentity;
    }
    
    - (IBAction)change:(id)sender {
        
        for (UIView* view
             in self.view.subviews) {
            view.backgroundColor = [UIColor redColor];
        }
    }
    @end
    

    相关文章

      网友评论

          本文标题:UIView的常见属性

          本文链接:https://www.haomeiwen.com/subject/ukjqrttx.html