• IOS7开发~新UI学起(一)


    本文转载至:http://blog.csdn.net/lizhongfu2013/article/details/9124893

    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 

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

     
    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
  • 相关阅读:
    【网络文摘】一位36岁程序员的困惑
    【网络文摘】大龄程序员怎样渡过中年危机?
    【问题与解决】showModalDialog is not defined 的解决方案
    【ASP.NET 问题】ASP.NET 网站404页面返回200,或者302的解决办法
    IIS 网站 HTTP 转 HTTPS
    ECharts JS应用:图表页面实现
    【问题与解决】怎么删除TFS云端上的项目
    【问题与解决】Github 上传代码报错(error:1407742E:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert protocol version)
    【问题与解决】Mac OS通过 npm 安装 React Native 报错(checkPermissions Missing write access to /usr/local/lib/node_modules)
    【JavaScript 插件】图片展示插件 PhotoSwipe 初识
  • 原文地址:https://www.cnblogs.com/Camier-myNiuer/p/3429180.html
Copyright © 2020-2023  润新知