iPhone基础开发之自定义Button
2011-07-31 20:47
183 查看
在绝大部分IOS应用的开发过程中,都不会使用IB, 使用代码自定义界面控件尤其重要。 本文就介绍下如何用代码自定义BUTTON控件。
添加按键响应:
[pBtn addTarget:self
action:@selector(buttonTest:)
forControlEvents:UIControlEventTouchUpInside];
- (void)buttonTest:(id)sender
{
NSLog(@"button test");
}
UIButton *pBtn=[UIButton buttonWithType:UIButtonTypeRoundedRect]; //使用这个类方法来初始化button对象 [pBtn setTitle:@"MyButton" forState:UIControlStateNormal]; [pBtn setFrame:CGRectMake(10, 20, 80, 30)]; [pView addSubview:pBtn];
添加按键响应:
[pBtn addTarget:self
action:@selector(buttonTest:)
forControlEvents:UIControlEventTouchUpInside];
- (void)buttonTest:(id)sender
{
NSLog(@"button test");
}
相关文章推荐
- Iphone开发(十二)通过xib文件自定义列表中的行
- (2)iPhone开发基础-Hello World
- unity基础开发----切换场景、游戏视图(Game View)、iphone优化
- Objective-C ,ios,iphone开发基础:ios判断图片为png还是jpg或者jepg
- Android 仿 Iphone 自定义滑动按钮(SlipButton)
- iOS开发UI篇—Button基础
- iPhone应用开发之一:窗口,视图,视图控制器和UIKit基础
- IPhone开发之C基础(一)
- iOS开发UI篇—Button基础
- Objective-C ,ios,iphone开发基础:http网络编程
- (android 基础知识) android Button 自定义点击效果
- Iphone开发基础教程 example4
- --iPhone开发基础 - 计划
- 【iPhone代码片段之八】如何自定义Tab Bar Button
- [ios]iPhone地图应用开发以及自定义Annotation [转]
- iPhone开发教程 UI基础课程(58课时)
- iphone开发之自定义UIPageControl小图标
- iPhone开发【十八】自定义视图之ActionSheet中使用PickerView
- [置顶] Objective-C ,ios,iphone开发基础:在UITextField输入完以后,隐藏键盘,
- 【Cocos2dX(2.x)_Lua开发之三】★重要必看篇★在Lua中使用自定义精灵(Lua脚本与自创建类之间的访问)及Lua基础讲解