zoukankan      html  css  js  c++  java
  • 关于一个小应用软件的思考

    1 iOS7 的self.view.frame的横屏和竖屏都是一样 的,iOS8的self.view.frame是不一样的,

    CustomIOSAlertView可以弹出图片

    - (void)viewWillLayoutSubviews 当设备旋转时会调用此方法重新布局。

     (1)UIDevice *device = [UIDevice currentDevice] ;  if (device.orientation ==UIDeviceOrientationLandscapeLeft ||device.orientation ==UIDeviceOrientationLandscapeRight);

        (2) if (UIInterfaceOrientationIsLandscape(self.interfaceOrientation))

        (3)UIInterfaceOrientation or; if (or == UIDeviceOrientationLandscapeLeft ||or == UIDeviceOrientationLandscapeRight)

    以上三个方法都可以判断设备的方向

    #pragma mark

    #pragma - mark 根据UIColor生成对应颜色的图片

    /**

     *  根据UIColor生成对应颜色的图片

     *

     *  @param color UIColor

     *  @param size  目标图片的尺寸

     *

     *  @return 对应颜色的图片

     */

    - (UIImage *)imageWithColor:(UIColor *)color andSize:(CGSize)size

    {

        CGRect rect = CGRectMake(0.0f, 0.0f, size.width, size.height);

        UIGraphicsBeginImageContext(rect.size);

        CGContextRef context = UIGraphicsGetCurrentContext();

        CGContextSetFillColorWithColor(context, [color CGColor]);

        CGContextFillRect(context, rect);

        UIImage *image = UIGraphicsGetImageFromCurrentImageContext();

        UIGraphicsEndImageContext();

        return image;

    }

     

    #pragma mark

    #pragma - mark 重新设置图片的尺寸

    /**

     *  重新设置图片的尺寸

     *

     *  @param image 原来的图片

     *  @param size  目标图片的大小

     *

     *  @return 目标图片

     */

     

    7

    -(UIImage*) OriginImage:(UIImage *)image scaleToSize:(CGSize)size

    {

        UIGraphicsBeginImageContext(size);  //size CGSize类型,即你所需要的图片尺寸

        

        [image drawInRect:CGRectMake(0, 0, size.width, size.height)];

        

        UIImage* scaledImage = UIGraphicsGetImageFromCurrentImageContext();

        

        UIGraphicsEndImageContext();

        

        return scaledImage;   //返回的就是已经改变的图片

    }

     

    8

    #pragma mark

    #pragma - mark 把十六进制的颜色表示转换为 UIColor

    /**

     *  把十六进制的颜色表示转换为 UIColor

     *

     *  @param color 十六进制的颜色

     *

     *  @return UIColor

     */

    - (UIColor *)hexToUIColor:(NSString *)hexcolor

    {

        // 十六进制字符串转成整形。

        long colorLong = strtoul([hexcolor cStringUsingEncoding:NSUTF8StringEncoding], 0, 16);

        // 通过位与方法获取三色值

        int R = (colorLong & 0xFF0000 )>>16;

        int G = (colorLong & 0x00FF00 )>>8;

        int B =  colorLong & 0x0000FF;

        

        //stringcolor

        UIColor *wordColor = [UIColor colorWithRed:R/255.0 green:G/255.0 blue:B/255.0 alpha:1.0];

        return wordColor;

    }

    10  iOS8 新加了一个类UIAlertController

    11  判断系统版本[[[UIDevice currentDevice] systemVersion] floatValue];

  • 相关阅读:
    linux中你会新建复制移动删除文件或目录吗?三分钟搞懂【文件管理】
    从此英语渣渣也能看懂man手册-【linux man手册汉化安装使用教程】
    你真的会用ls命令吗?--文件管理命令(ls命令详解)
    Python算法系列—深度优先遍历算法【二叉树】
    Python算法系列-单词匹配模式【hash练习】
    abp 从4.3升级到5.4 从入门到放弃
    ABP core2.2错误笔记2,持续更新
    echart报错: Component series.XXX not exists. Load it first
    单例模式MQTT服务为什么会重复收到消息
    在ABP core中使用RabbitMq
  • 原文地址:https://www.cnblogs.com/shanyimin/p/4628280.html
Copyright © 2011-2022 走看看