iOS中的按钮(UIButton)
2015-08-27 22:22
211 查看
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease]; // Override point for customization after application launch. /** * UIButton:是iOS中用来响应用户点击事件的控件,是UIControl的子类 UIButton的使用步骤: 1.创建控件对象 2.配置属性 3.添加到父视图 */ //1.创建控件 UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom]; //UIButtonWtypeSystem 当给button设置图片的时候不用UIButtonTypeSystem //2.配置属性 // button.backgroundColor = [UIColor greenColor]; //(1)设置frame button.frame = CGRectMake(10, 100, 300, 40); //[button setTitle:@"注册" forState:UIControlStateNormal]; //[button setTitleColor:[UIColor blackColor] forState:UIControlStateNormal]; //设置图片 [button setImage:[UIImage imageNamed:@"login_btn_normal"] forState:UIControlStateNormal]; [button setImage:[UIImage imageNamed:@"login_btn_press"] forState:UIControlStateHighlighted]; //3.添加父视图 [self.window addSubview:button]; //4.添加响应事件 //self代表响应方法的对象 //target指定事件响应对象 //action:指定响应对象要调用的方法,来处理Button点击事件 //controlevents:事件触发的时机 //handleAction 方法可以有参数,而且参数只有一个,因为参数是调用addTarget:action:forControlEvent:方法的对象(就是实现该方法的button) [button addTarget:self action:@selector(thisButtonShow:) forControlEvents:UIControlEventTouchUpInside]; /** * 控件小结 每一个控件用来实现特定的功能 UILabel:用来显示文字 UITextField:用来进行文本的编译 UIButton:用来响应用户的交互事件,响应用户的点击事件,还可以显示文字和图片. */ self.window.backgroundColor = [UIColor whiteColor]; [self.window makeKeyAndVisible]; return YES; }
相关文章推荐
- iOS中的文本框(UITextField)
- 国内UED收录
- iOS中的UIView的基本属性
- iOS中的屏幕的旋转(UIViewController)横屏竖屏
- iPhone开发之UIScrollView滚动组件的使用(二) 拖线实现按钮控制大图移动利用contentOffset属性
- 玩转UITableView
- iOS:转载:UIControl的使用
- iOS中的分段控件(UISegmentedControl)和滑块控件(UISlider)
- UILabel 详解
- 【APUE】Chapter11 Threads
- UI_10 表视图的编辑、UITableViewController
- 在QT Creator中简单的使用UI文件来设计界面并在源码中使用ui文件
- UI基础----常见控件的使用之TextView
- Qt学习(1):ui设计给窗口做背景及控件背景添加方法
- iPhone开发之UIScrollView滚动组件的使用——纯代码实现图形的横向与纵向滚动
- iOS中的导航条UINavigationController(UISegmentedControl)的基本使用(界面中传值的3中方法,单例,属性,代理)
- [uwsgi] no request plugin is loaded, you will not be able to manage requests.
- iOS中的分页控件(UIPageControl)
- iOS中的UIScorllView(滑动控件,时机控制)的基本使用
- CircuitBreakingException[[FIELDDATA] Data too large, data for [proccessDate] would be larger than li