|
<div id="cnblogs_post_body">iOS开发点击UIButton实现UIView的旋转
更多阅读请访问http://www.hopean.com
http://www.hopean.com
首先创建界面,在viewDidLoad创建view以及button
相关代码如下
<div class="cnblogs_code">-(void)viewDidLoad{ [super viewDidLoad]; viewDemo = [[UIView alloc] initWithFrame:CGRectMake(0, 50, 320, 50)]; [viewDemo setBackgroundColor:[UIColor brownColor]]; UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 100, 50)]; label.text =@"Test"; label.tag=100; [viewDemo addSubview:label]; [self.view addSubview:viewDemo]; [label release]; // Do any additional setup after loading the view, typically from a nib. UIButton *btn = [[UIButton alloc] initWithFrame:CGRectMake(0, 400, 100, 50)]; [btn setBackgroundColor:[UIColor blueColor]]; btn.showsTouchWhenHighlighted = YES; [btn setTitle:@"点击旋转" forState:UIControlStateNormal]; [self.view addSubview:btn]; btn.tag = 10010; [btn addTarget:self action:@selector(testViewDemo) forControlEvents:UIControlEventTouchUpInside]; [btn release]; number = 0; } |
|