标签: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;
}
标签:style tar ext color get string
原文地址:http://www.cnblogs.com/mingtiannihao/p/3791813.html