码迷,mamicode.com
首页 > 其他好文 > 详细

上移view

时间:2014-06-18 13:41:02      阅读:185      评论:0      收藏:0      [点我收藏+]

标签:style   tar   ext   color   get   string   

上移view

#import "MingRootViewController.h"

 

@interface MingRootViewController ()

{

    UIView *_myView;

    UIView *_myView1;

    BOOL _flag;

}

 

@end

 

@implementation MingRootViewController

 

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil

{

    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];

    if (self) {

        // Custom initialization

        _flag = NO;

    }

    return self;

}

 

- (void)viewDidLoad

{

    [super viewDidLoad];

    _myView1 = [[UIView alloc]initWithFrame:CGRectMake(0, 440, 320, 40)];

    _myView1.backgroundColor = [UIColor blackColor];

    [self.view addSubview:_myView1];

    

    _myView = [[UIView alloc]initWithFrame:CGRectMake(0, 440, 320, 40)];

    _myView.backgroundColor = [UIColor cyanColor];

    [self.view addSubview:_myView];

 

    self.button = [UIButton buttonWithType:UIButtonTypeSystem];

    self.button.frame = CGRectMake(50, 330, 200, 40);

    [self.button setTitle:@"测试" forState:UIControlStateNormal];

    [self.button addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];

    [self.view addSubview:self.button]; 

}

 

 

- (void)buttonAction:(UIButton *)sender

{

    if (!_flag) {

        [UIView beginAnimations:nil context:nil];

        

        _myView.transform = CGAffineTransformTranslate(_myView.transform, 0, -40);

        [UIView setAnimationDuration:2.f];

        _flag = YES;

    }else{

        [UIView beginAnimations:nil context:nil];

        

        _myView.transform = CGAffineTransformTranslate(_myView.transform, 0, 40);

        [UIView setAnimationDuration:2.f];

        _flag = NO;

    }

 

 

 

 

上移view,布布扣,bubuko.com

上移view

标签:style   tar   ext   color   get   string   

原文地址:http://www.cnblogs.com/mingtiannihao/p/3791813.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!