#import "AppDelegate.h"
@interface AppDelegate ()
@end
@implementation AppDelegate
- (void)dealloc
{
[_window release];
[super dealloc];
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
[_window release];
// 用button自己的便利构造器的方式来创建对象
UIButton *button = [UIButton buttonWithType:UIButtonTypeSystem];
// 指定button的位置和大小
button.frame = CGRectMake(100, 100, 150, 70);
button.backgroundColor = [UIColor cyanColor];
[self.window addSubview:button];
// button不用release
// 给button设置标题
[button setTitle:@"确认" forState:UIControlStateNormal];
// 标题的字体大小
button.titleLabel.font = [UIFont systemFontOfSize:40];
// 设置下圆角
button.layer.cornerRadius = 20;
// 边框
button.layer.borderWidth = 1;
/// 点击方法 button最重要的方法
[button addTarget:self action:@selector(click:) forControlEvents:UIControlEventTouchUpInside];
return YES;
}
- (void)click:(UIButton *)button{
NSLog(@"测试按钮的点击方法");
}