zoukankan      html  css  js  c++  java
  • iOS-UIScreen,UIFont,UIColor,UIView,UIButton

    6.1 UIScreen

    // 屏幕的宽度

    CGFloat screenW = [UIScreen mainScreen].bounds.size.width;

    6.2 UIFont

    + (UIFont *)systemFontOfSize:(CGFloat)fontSize;   系统默认字体

    + (UIFont *)boldSystemFontOfSize:(CGFloat)fontSize;  粗体

    + (UIFont *)italicSystemFontOfSize:(CGFloat)fontSize;  斜体

    6.3 UIColor
    /利用UIColor给背景颜色赋值
    textLable.backgroundColor = [UIColor redColor];
    //自定义RGB颜色
    [UIColor colorWithRed:140/255.0f green:30/255.0f blue:94/255.0f alpha:1];
    //背景透明

    [UIColor clearColor];

    6.4 UIView
    6.4.1 frame、center、bounds、transform
     frame:用作控件初始化

    center:可用作平移

    bounds:可用作缩放

    transform:位移、缩放、旋转都可用,但不能与frame混用
     
    6.4.4 动画效果 首尾动画

    [UIView beginAnimations:nil context:nil];

    [UIView setAnimationDelay:0.3f];

    self.imgButton.center = p;

    [UIView commitAnimations];

    6.4.5 block动画效果

    //block嵌套动画,先1秒钟时间显示label,finish后执行嵌套动画

    //内嵌动画中,延迟2秒执行,首先1秒钟时间匀速隐藏label,finish后移除label

    label.alpha = 0.0;

    [UIView animateWithDuration:1.0f animations:^{

       label.alpha = 0.5;

    } completion:^(BOOL finished) {

       [UIView animateWithDuration:1.0f delay:2.0f options:UIViewAnimationOptionCurveEaseInOutanimations:^{

           label.alpha = 0.0f;

       } completion:^(BOOL finished) {

           [label removeFromSuperview];

       }];

    }];

     6.4.6 动态创建

     [self.view addSubview:appView];

     6.4.7 圆角处理

    .layer.cornerRadius = 5;

    .layer.masksToBounds = YES;

    6.4.8 子控件前置显示

    [self.view bringSubviewToFront:self.imageIcon];

    6.4.9 常用事件

    //当前控件布局时触发,子控件初始化frame需要用到父控件的frame时,需要写在此事件中

    - (void)layoutSubviews;
     // 重写layoutSubviews方法时,必须调用[supper layoutSubviews],否则控件不响应事件。

    // 在每个headerView被添加到某个父控件中后触发.

    - (void)didMoveToSuperview。

      

    6.4.10 常用属性

    //内容保持相同的尺寸

    btnGroupName.imageView.contentMode = UIViewContentModeCenter;
    //当YES时,内容和子视图被剪切到视图的边界。

    btnGroupName.imageView.clipsToBounds = NO;

    6.4.11 背景透明与clearColor

    当view背景颜色设置为clearColor时,被view覆盖的按钮虽然可以显示,但无法点击。当如果将设置view的透明度为0,则按钮既能显示,也可以点击。

     //设置背景颜色
    view1.backgroundColor = [UIColor clearColor];
    //设置透明度
    view1.alpha = 0;
     
       UIButton 的使用
    有default,highlighted,selected,不可用状态
     
    常用属性设置

    //设置按钮的文字

    - (void)setTitle:(NSString *)title forState:(UIControlState)state;

    //设置按钮的文字颜色

    - (void)setTitleColor:(UIColor *)color forState:(UIControlState)state;

    //设置按钮内部的小图片

    - (void)setImage:(UIImage *)image forState:(UIControlState)state;

    //设置按钮的背景图片

    - (void)setBackgroundImage:(UIImage *)image forState:(UIControlState)state;

    //设置按钮的文字字体(需要拿到按钮内部的label来设置)

    btn.titleLabel.font = [UIFont systemFontOfSize:13];

    //设置按钮边缘间距

    UIEdgeInsets insets = UIEdgeInsetsMake(0, 50, 0, 0);

    self.button.contentEdgeInsets = insets;//对image和titleLabel同时有效

    self.button.titleEdgeInsets = insets;//仅对titleLabel有效

    self.button.imageEdgeInsets = insets;//仅对image有效

    常用属性获取

    //获得按钮的文字

    - (NSString *)titleForState:(UIControlState)state;

    //获得按钮的文字颜色

    - (UIColor *)titleColorForState:(UIControlState)state;

    //获得按钮内部的小图片

    - (UIImage *)imageForState:(UIControlState)state;

    //获得按钮的背景图片

    - (UIImage *)backgroundImageForState:(UIControlState)state;

      addTarget绑定事件

  • 相关阅读:
    Python中利用xpath解析HTML
    常见聚类算法——K均值、凝聚层次聚类和DBSCAN比较
    格式化字符串format函数
    编程语言这个垂直方向
    CLR,GC 表示什么意思?
    ASP.Net MVC开发基础学习笔记:一、走向MVC模式
    NPOI 通过excel模板写入数据并导出
    SQL 注意事项
    解决微信公众号OAuth出现40029(invalid code,不合法的oauth_code)的错误
    iis 站点中文乱码 解决方案
  • 原文地址:https://www.cnblogs.com/linxiu-0925/p/5058108.html
Copyright © 2011-2022 走看看