导航栏、工具栏高
(返回
)
44 像素
隐藏状态栏
[[UIApplication shareApplication] setStatusBarHidden: YES animated:NO]
横屏
[[UIApplication shareApplication]
setStatusBarOrientation:UIInterfaceOrientationLandscapeRight].
屏幕变动检测
orientation == UIInterfaceOrientationLandscapeLeft
全屏
window=[[UIWindow alloc] initWithFrame:[UIScreen mainScreen] bounds];
自动适应父视图大小:
aView.autoresizingSubviews = YES;
aView.autoresizingMask = (UIViewAutoresizingFlexibleWidth |
UIViewAutoresizingFlexibleHeight);
定义按钮
UIButton *scaleUpButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[scaleUpButton setTitle:@"放 大" forState:UIControlStateNormal];
scaleUpButton.frame = CGRectMake(40, 420, 100, 40);
[scaleUpButton addTarget:self
action:@selector(scaleUp)
forControlEvents:UIControlEventTouchUpInside];
设置视图背景图片
UIImageView *aView;
[aView setImage:[UIImage imageNamed:@”name.png”]];
view1.backgroundColor = [UIColor colorWithPatternImage:
[UIImage imageNamed:@"image1.png"]];
自定义
UISlider 的样式和滑块
我们使用的是
UISlider 的 setMinimumTrackImage,和 setMaximumTrackImage 方法来定义图
片的,这两个方法可以设置滑块左边和右边的图片的,不过如果用的是同一张图片且宽度
和控件宽度基本一致,就不会有变形拉伸的后果,先看代码,写在
viewDidLoad 中:
//左右轨的图片
UIImage *stetchLeftTrack= [UIImage imageNamed:@"brightness_bar.png"];
UIImage *stetchRightTrack = [UIImage imageNamed:@"brightness_bar.png"];
//滑块图片