UIButton 详解

来源:互联网 发布:mysql 时间虚表 编辑:程序博客网 时间:2024/06/05 11:56
UIButton 详解
http://www.cnblogs.com/sell/archive/2013/02/04/2891769.html
 1 UIButton *bt = [UIButton buttonWithType:UIButtonTypeContactAdd];// UIButtonTypeCustom, UIButtonTypeRoundedRect; // 2     [bt setTitle:@"myButton" forState:UIControlStateNormal];        // 普通状态 3     [bt setTitle:@"Button1" forState:UIControlStateHighlighted];    // 触摸时 4     [bt setTitle:@"disButton" forState:UIControlStateDisabled];     // 无效时 5     [bt setTitleColor:[UIColor redColor] forState:UIControlStateNormal];    // 普通状态下的字体颜色 6      7     bt.titleLabel.font = [UIFont boldSystemFontOfSize:24];  // 按钮字体 8     bt.titleLabel.shadowOffset = CGSizeMake(1, 1); 9     bt.titleLabel.shadowColor = [UIColor redColor];10     11     12     [bt setImage:[UIImage imageNamed:@"normal.png"] forState:UIControlStateNormal];13     // 普通状态下图片,只在UIButtonTypeCustom,UIButtonTypeRoundedRect下有效14     [bt setBackgroundImage:[UIImage imageNamed:@"background.png"] forState:UIControlStateNormal]; // 设置背景图15     16     UIEdgeInsets insets;    // 设置按钮内部图片间距17     insets.top = insets.bottom = insets.right = insets.left = 10;18     bt.contentEdgeInsets = insets;19     20     bt.titleEdgeInsets = insets;    // 标题间距21     22     [bt addTarget:self23            action:@selector(click:)24  forControlEvents:UIControlEventTouchUpInside]; // 添加事件响应

0 0
原创粉丝点击