IOS7开发~新UI学起(一)

来源:互联网 发布:淘宝联盟权限有什么 编辑:程序博客网 时间:2024/05/06 01:13

IOS7在UI方面发生了很大改变,所以感觉有必要重新审视的学习一下(新特性+以前未注意到的特性)。

现在开始了:


1、UIView:


a)view.clearsContextBeforeDrawing =YES  <IOS6>

When the Clears Graphics Context (clearsContextBeforeDrawing) checkbox is selected, the drawingbuffer is automatically cleared to transparent black before the view is drawn. This behavior ensures thatthere are no visual artifacts left over when the view’s contents are redrawn. (UIView每次重会之前,清除掉上次的内容,由于系统默认就是YES,所以忽略这个特性了,这个特性不是IOS7才有的)


b)Appearance Proxies  <IOS6>

代码和效果图:

1>To customize the appearance of all instances of a class, useappearanceto get the appearance proxy forthe class (让某一类控件同时表现某种属性)

    [[UIButton appearance]setBackgroundColor:[UIColorredColor]];

    [[UIButton appearance]setTitle:@"ssss"forState:UIControlStateNormal];

2>

To customize the appearances for instances of a class when contained within an instance of a containerclass, or instances in a hierarchy, you useappearanceWhenContainedIn:to get the appearance proxyfor the class. (

让某一类控件在另一种控件中同时表现某种属性

)

    

[[UIButton  appearanceWhenContainedIn:[UIView  class],nil]  setTitleColor:[UIColor   greenColor]

                                                                   forState:UIControlStateNormal];



Appearance Proxies 特性在IOS7以前可用,但并不那么显眼,但IOS7之后,由于UI的外表的改变,看起来更明显了,如图:


注意:

You can use an appearance proxy to set particular appearance properties for all instances of a view in yourapplication. (所有继承自UIView的控件都有这个特征,只不过不同的控件会以不同的方式展现这个特性)

更多代码:

[[UISlider appearance] setMinimumTrackTintColor:[UIColor greenColor]];
[[UISlider appearanceWhenContainedIn:[UIView class], nil]
            setMinimumTrackTintColor:[UIColor greenColor]];


c)Using Template Images <IOS7>

模版图片:

UIImage *myImage = [UIImage imageNamed:@"myImageFile.png"];
myImage = [myImage imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];


UIImageRenderingModeAutomatic,          // Use the default rendering mode for the context where the image is used
UIImageRenderingModeAlwaysOriginal,     // Always draw the original image, without treating it as a template
UIImageRenderingModeAlwaysTemplate,     // Always draw the image as a template image, ignoring its color information
这个不理解有什么用,高人指点~~

d)

Using Auto Layout with Views 

看这几篇,应该可以入门:

http://blog.csdn.net/zfpp25_/article/details/8861221


2、

UIActionSheet

:<IOS7样式>



不要吃惊,屏幕下方的真的是UIActionSheet,实现方式没有改变,但就是这样式……

UIActionSheet *actionSheet = [[UIActionSheetalloc]initWithTitle:nil

                                                             delegate:nil

                                                    cancelButtonTitle:@"Cancel"

                                               destructiveButtonTitle:@"Delete"

                                                    otherButtonTitles:@"one", @"two",nil];

  [actionSheet showInView:self.view];


3、UIActivityIndicatorView

    [[UIActivityIndicatorViewappearance]setColor:[UIColorblueColor]];

    UIActivityIndicatorView *indicator = [[UIActivityIndicatorViewalloc]initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];

    indicator.frame = CGRectMake(180,100,100,100);

    [self.view addSubview:indicator];

    [indicator startAnimating];


   这样一看,转圈也好像顺眼多了。


4、UIAlertView:
<IOS7样式>

实现方式没有改变



注意:

1、做版本兼容时候,发现 UIAlertView 的 visible 属性貌似失效了。


5、UICollectionView  
<IOS6>

高级控件,适合做相册效果:http://blog.sina.com.cn/s/blog_5a6efa330101doc9.html



其他:

IOS7开发~UI学起(二)

IOS7开发~UI学起(三)

IOS7开发~UI学起(四)