UIImageView-UIAlertView-UIActionSheet.
UIImageView
- 一个显示图片控件,直接继承了UIView基类,没有继承UIControl,不能接受用户输入,不能与用户交互。
- 常用属性
image:访问或设置该控件显示的图片highlighteImage:访问或设置该控件出于高亮状态时显示的图片 - UIImage还可以使用动画显示一组图片
animationImages:访问或者设置该UIImageView需要动画显示的多张图片,该属性的值为NSArray对象。highlightedAnimationImages:访问或设置该UIImageView高亮状态下需要动画显示的多张图片,该属性的值为NSArray对象。animationDuration:访问或设置该UIImageView的动画持续时间。animationRepeatCout:访问或设置该UIImageView的动画重复次数。startAnimating:开始播放动画。stopAnimating:停止播放动画。isAnimationg:该方法判断该UIImageView是否正在播放动画。 - 缩放模式
Scale To Fill:不保持纵横比缩放图片,使图片完全适应该UIImageView控件。Aspect Fit:保持纵横比缩放图片,使图片的长边能完全显示出来。也就是说,可以完整地将图片显示出来。Aspect Fill:保持纵横比缩放图片,只保证短边完全显示出来。Center:不缩放图片,只显示图片的中间区域。Top:不缩放图片,只显示图片的顶部区域。Bottom:不缩放图片,只显示图片的底部区域。Left:不缩放图片,只显示图片的左边区域。Right:不缩放图片,只显示图片的右边区域。Top Right:不缩放图片,只显示图片的右上边区域。Top Left:不缩放图片,只显示图片的左上边区域。Bottom Left:不缩放图片,只显示图片的左下边区域。Bottom Right:不缩放图片,只显示图片的右下边区域。
UIAlertView(警告框)
- UIAlertView
- 显示在屏幕中央的弹出式警告框。
- 基本用法
- 创建
UIAlertView,指定标题、消息内容、包含多少个按钮、指定UIAlertViewDelegate委托对象。 - 调用
UIAlertView显示出来。 - 实现
UIAlertViewDelegate协议中的方法。
- 创建
- 实例代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25-(void)viewDidLoad
{
[super viewDidLoad];
}
-(IBAction)clicked:(id)sender
{
UIAlertView *alert = [[UIAlertView alloc]
initWithTitle:@"提示"
message:@"警告框信息"
deledgate:self
cancelButtonTitle:@"确定"
otherButtonTitles:@"按钮一",@"按钮二",@"按钮三",nil];
[alert show];
}
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
NSString* msg = [NSString stringWithFormat:@"你点击了第%d按钮",buttonIndex];
UIAlertView *alert = [[UIAlertView alloc]
initWithTitle:@"提示"
message:msg
delegate:nil
cancelButtonTitle:@"确定"
otherButtonTitles:nil];
[alert show]
}- UIAlertViewDelegate协议中常用的方法
1 | -(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex: |
+ 带输入框的UIAlertView
- UIAlertView支持actionSheetStyle属性,用于设置该UIAlert的风格,支持如下枚举值:
`UIAlertViewStyleDefault`:默认的警告框风格。
`UIAlertViewStyleSecureTextInput`:警告框中包含一个密码输入框。
`UIAlertViewStylePlainTextInput`:警告框中包含一个普通的输入框。
`UIAlertViewStyleLoginAndPasswordInput`:警告框中包含用户名、密码两个输入框。
+ 实例代码
1 | -(void)viewDidLoad |
UIActionSheet
显示在底部的按钮列表,用户通过单击某个按钮来表明自己的态度。
- 风格(actionSheetStyle):
UIActionSheetStyleDefault:默认风格,灰色背景上显示白色文字。
UIActionSheetStyleBlackTranslucent:在透明的黑色背景上显示白色文字。
UIActionSheetStyleBlackOpaque:在纯黑的背景上显示白色文字示例代码
1 | -(void)viewDidLoad |

