2.21 Adding Buttons to the User Interface with UIButton
来源:互联网 发布:云计算的安全问题包括 编辑:程序博客网 时间:2024/05/21 06:01
增加button并处理button事件
button可以有多个触发事件,比如可以是按下去时触发,也可以是放开按钮时触发,触发的事件可以是一样的,也可以是不一样的。
//可以再不同状态下显示不同的标题
[self.myButton setTitle:@"Press Me" forState:UIControlStateNormal];
[self.myButton setTitle:@"I'm Pressed" forState:UIControlStateHighlighted];
//可以对不同的事件触发不同的方法
[self.myButton addTarget:self action:@selector(buttonIsPressed:) forControlEvents:UIControlEventTouchDown];
[self.myButton addTarget:self action:@selector(buttonIsTapped:) forControlEvents:UIControlEventTouchUpInside];
//不同状态下显示不同的背景图 (这时他的UIButtonType应该设置成UIButtonTypeCustom)
[self.myButton setBackgroundImage:normalImage forState:UIControlStateNormal];
[self.myButton setBackgroundImage:highlightedImage forState:UIControlStateHighlighted];
我们可以用setBackgroundImage:forState:设置背景图,这时我们也可以setTitle:forState:在背景图上显示文字。如果不想显示文字,可以把title置空,或干脆用setImage:forState:
- 2.21 Adding Buttons to the User Interface with UIButton
- Adding the Action Bar - Adding Action Buttons
- 【English】Android -> Training -> Adding the Action Bar -> Adding Action Buttons
- How To Use the GitLab User Interface To Manage Projects
- 2.15 Adding Buttons to Navigation Bars Using UIBarButtonItem
- ios: UI学习总结(user Interface)UIButton
- 04 Adding Action Buttons
- Adding Action Buttons
- How to make sexy buttons with CSS
- Adding Controls to the Toolbar
- Adding the PPA to Ubuntu
- Adding Validation to the Model
- Databinding to user Interface controls
- The Yahoo! User Interface Library
- Effects with the Pixel Bender Toolkit – Part 3: Adding parameters to filters
- The Essential Guide to User Interface Design: An Introduction to GUI Design Principles and Technique
- GUI2Exe is a Graphical User Interface frontend to all the "executable builders" available for the Py
- Adding new icon to toolbar with script
- Android拍照和取相册并裁切
- Macintosh HFSPlus Filesystem for Linux
- Button
- laravel 实现 模块式开发
- Documentation/resource-control.txt
- 2.21 Adding Buttons to the User Interface with UIButton
- 在 Visual Studio 2010 中创建 ASP.Net Web Service
- JAVA学习第二天笔记
- 韩顺平网页第二十四讲,二十五讲,二十六讲
- [原]在MAC里启动和停止的MySQL和PostgreSQL的的指令
- 做人那点儿事
- 解决pear使用时出现 PHP_PEAR_INSTALL_DIR is not set correctly.
- jQuery插件之表格排序(转后完善)
- (二叉堆10.2.1)ZOJ 2724 Windows Message Queue(对结构体使用优先队列)