(iOS软件开发UI部分)UIButton基本使用
来源:互联网 发布:四大台柱 知乎 编辑:程序博客网 时间:2024/04/27 21:20
#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];
/******************** UIButton *********************/
// 创建一个button
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
// 为button设置大小
button.frame =CGRectMake(100, 100, 50, 40);
// button背景颜色
button.backgroundColor = [UIColor grayColor];
// 设置button字体
[button setTitle:@"点击" forState:UIControlStateNormal];
// 设置颜色
[button setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
// 设置图片(前景)
[button setImage:[UIImage imageNamed:@"1.png"] forState:UIControlStateNormal];
// 获取指定前景照片
UIImage *image = [button imageForState:UIControlStateNormal];
// 设置背景图片
[button setBackgroundImage:[UIImage imageNamed:@"2.jpg"] forState:UIControlStateNormal];
// 获取指定背景图片
UIImage *image1 = [button backgroundImageForState:UIControlStateNormal];
// 判断是否被点击
button.selected = YES;
// 按钮是否可用
button.enabled = YES;
/**
* 为button添加点击事件
*/
// 1.添加
[button addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
/**
为button移除事件
*/
[button removeTarget:self action:@selector(removeButtonAction:) forControlEvents:UIControlEventTouchUpInside];
/******************** UIAlertView *********************/
// 警告框
//(1)创建
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"提示" message:@"您有一百万元到账!" delegate:nil cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil];
//(2)显示
[alertView show];
//(3)释放
[alertView release];
[self.window makeKeyAndVisible];
return YES;
}
// 2.实现事件
- (void)buttonAction:(UIButton *)button{
self.window.backgroundColor = [UIColor yellowColor];
}
- (iOS软件开发UI部分)UIButton基本使用
- iOS开发UI系列之UIButton的基本使用
- 【iOS开发】简单UI部分UIButton的创建和UITextField的使用
- 【iOS 开发】基本 UI 控件详解 (UIButton | UITextField | UITextView | UISwitch)
- iOS开发UI篇 -- UIButton
- iOS开发笔记-UI-UIButton
- IOS--UI--UIButton的使用
- iOS-UI-基本控件之UIButton
- iOS开发UI技巧篇 -- UIButton
- IOS开发中UI部分UIWebView简单使用<代码演示>
- IOS的基本控件的使用-UIButton
- IOS ui基础 uibutton
- IOS UI控件 - UIButton
- IOS UI 手写 UIButton
- iOS开发UI篇—UITableview控件基本使用
- iOS开发UI基础—19UITableview控件基本使用
- iOS开发UI篇—UITableview控件基本使用
- iOS开发UI篇—UITableview控件基本使用
- 软件设计师考点之-设计模式
- 新手使用长按手势将网络图片保存至系统相册出现的问题
- 图解数据结构——二叉堆
- APM相关
- 获取GridView中RowCommand的当前索引行
- (iOS软件开发UI部分)UIButton基本使用
- 面试题 10
- nth_element-第n小数
- Axure学习之简介
- JS中各种继承方式对比
- DataSet与实体类(转)
- 孤独的7 虫蚀算-穷举法
- maven pom文件详解
- Android学习系列之(七)Fragment深入