zoukankan      html  css  js  c++  java
  • HUD总结

    HUD

    • 指示器/HUD/遮盖/蒙板
    • 半透明的指示器如何实现
      • 指示器的alpha = 1.0;
      • 指示器的背景色是半透明的

    1. 创建颜色

    • 直接创建对应的颜色
    + (UIColor *)blackColor;      // 0.0 white
    + (UIColor *)darkGrayColor;   // 0.333 white
    + (UIColor *)lightGrayColor;  // 0.667 white
    + (UIColor *)whiteColor;      // 1.0 white
    + (UIColor *)grayColor;       // 0.5 white
    + (UIColor *)redColor;        // 1.0, 0.0, 0.0 RGB
    + (UIColor *)greenColor;      // 0.0, 1.0, 0.0 RGB
    + (UIColor *)blueColor;       // 0.0, 0.0, 1.0 RGB
    + (UIColor *)cyanColor;       // 0.0, 1.0, 1.0 RGB
    + (UIColor *)yellowColor;     // 1.0, 1.0, 0.0 RGB
    + (UIColor *)magentaColor;    // 1.0, 0.0, 1.0 RGB
    + (UIColor *)orangeColor;     // 1.0, 0.5, 0.0 RGB
    + (UIColor *)purpleColor;     // 0.5, 0.0, 0.5 RGB
    + (UIColor *)brownColor;      // 0.6, 0.4, 0.2 RGB
    + (UIColor *)clearColor;      // 透明色
    • 根据RGB组合创建颜色
    + (UIColor *)colorWithRed:(CGFloat)red green:(CGFloat)green blue:(CGFloat)blue alpha:(CGFloat)alpha;

    2. 渐变动画

    • 方法1: 头尾式
    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:2.0];
    /*需要执行的动画的代码*/
    [UIView commitAnimations];
    • 方法2: 渐变式
    //动画执行两秒钟
    [UIView animateWithDuration:2.0 animations:^{
            self.shopsView.alpha = 0.0;//透明度变为0.0
        }];
    
    //1s后再执行动画,动画执行两秒钟
    //options(动画的选项):kNilOptions    
    [UIView animateWithDuration:2.0 delay:1.0 options:kNilOptions animations:^{self.shopsView.alpha = 0.0;} completion:^(BOOL finished){NSLog(@"播放完毕");}];

    3. 按钮

    • 自定义按钮: 调整内部的子控件frame
      • 方法1: 实现titleRectForContentRect:和imageRectForContentRect:方法中分别设置
      • 方法2: 在layoutSubViews中设置
    • 内边距
    //设置按钮内容的内边距(影响到imageView和titleLabel)
    @property (nonatomic) UIEdgeInsets contentEdgeInsets;
    //设置titleLabel的内边距(影响到titleLabel)
    @property(nonatomic) UIEdgeInsets titleEdgeInsets;
    //设置imageView的内边距(影响到imageView)
    @property(nonatomic) UIEdgeInsets imageEdgeInsets;
    • 注意
      • 按钮内部的图片和文字是分状态显示的
      • 按钮内部的文字默认是白色

    4. 图片

    • 拉伸

      • 保护图片边缘
        • 去掉自动布局,设置frame就可以被应用
    • iOS5之前

    //只会中间的拉伸1*1部分
    //rightCapWidth = width - leftCapWidth - 1;
    //bottomCapWidth = width - topCapWidth - 1;
    
    - (UIImage *)stretchableImageWithLeftCapWidth:(NSInteger)leftCapWidth topCapHeight:(NSInteger)topCapHeight;
    • iOS5之后
    - (UIImage *)resizableImageWithCapInsets:(UIEdgeInsets)capInsets; // create a resizable version of this image. the interior(内部) is tiled(平铺的) when drawn(拉伸).
    
    (UIEdgeInsets)capInsets-->UIEdgeInsetsMake(top, left, bottom, right)
    
    //resizingMode: 拉伸模式
    - (UIImage *)resizableImageWithCapInsets:(UIEdgeInsets)capInsets resizingMode:(UIImageResizingMode)resizingMode;
     

    5. pragma mark - 控制状态栏的样式

    - (UIStatusBarStyle)preferredStatusBarStyle
    {
        //白色
        return UIStatusBarStyleLightContent;
    }
  • 相关阅读:
    快速入门各种跨域
    常用知识点
    比较少用的格式
    git
    “没有用var声明的为全局变量”这种说法不准确
    类数组对象
    函数上下文的变量对象实例
    var a =10 与 a = 10的区别
    原型链与作用域链、执行上下文
    闭包的作用
  • 原文地址:https://www.cnblogs.com/HMJ-29/p/4758667.html
Copyright © 2011-2022 走看看