关于一个小应用软件的思考

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];

原文地址:https://www.cnblogs.com/shanyimin/p/4628280.html