frame:
修改大小后,原先的左上角的坐标不会改变,既以原来的左上角坐标位置保持不变为前提进行尺寸的改变。
bounds
功能同frame,不同之处在于,以一身中点位置进行缩放。
修改位置的时候使用frame属性,它的坐标位置表示是的是一身在父空间种的坐标位置。
2、颜色设置:
+ (UIColor *)colorWithRed:(CGFloat)redgreen:(CGFloat)greenblue:(CGFloat)bluealpha:(CGFloat)alpha; 指定HSB,参数是:色调(hue),饱和的(saturation),亮度(brightness)
+ (UIColor *)colorWithHue:(CGFloat)huesaturation:(CGFloat)saturationbrightness:(CGFloat)brightnessalpha:(CGFloat)alpha;
UIColor *color = [UIColor redColor]; UIColor *cl = [color colorWithAlphaComponent:0.5f]; 自定义255的颜色值,将255转成0-1
在自定义View的时候 设置蒙版的颜色可以这样弄,蒙版用一个UIImageView来做 kenshin笔记
CGFloatR = (CGFloat) 225/255.0; CGFloatG = (CGFloat) 66/255.0; CGFloatB = (CGFloat) 88/255.0; CGFloat alpha = (CGFloat) 1.0; UIColor *myColorRGB = [ UIColorcolorWithRed:Rgreen:Gblue:Balpha: alpha ]; self.tableView.backgroundColor = myColorRGB;
3.IOS禁止横屏
4.
对键盘的隐藏——点击空白处隐藏、点击return键隐藏
5.
键盘出现时,后面的视图整体上移的方法
3.IOS禁止横屏(两种方式) 可以通过 cmd +右 方向键 在模拟器中测试
- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
return UIInterfaceOrientationMaskPortrait;
}
4.对键盘的隐藏——点击键盘return键隐藏键盘、点击空白处隐藏键盘、
2.1在需要实现的控制器中实现代理<UITextFieldDelegate>
点击空白处隐藏键盘、
#pragma mark view代理 点击空白区域是触发
- (void)viewDidLoad
#pragma mark 键盘 高度的计算
}
6、我的工具类[宏定义等]
// // Tools.m // Device // // Created by kenshin on 15-9-9. // Copyright (c) 2015年 kenshin. All rights reserved. // #import <Foundation/Foundation.h> #import <sqlite3.h> //获取手机屏幕的宽、高 #define screenWidth [[UIScreen mainScreen] bounds].size.width #define screenHeight [[UIScreen mainScreen] bounds].size.height //字体颜色 为蓝色==帮助页面的背景色 #define blueMyColor [UIColor colorWithRed:84.0/255 green:173.0/255 blue:235.0/255 alpha:1.0] #define colorMyButton [UIColor colorWithRed:0.0/255 green:122.0/255 blue:255.0/255 alpha:1.0]//参照IOS默认的Alert按钮颜色 #define colorPageIn [UIColor colorWithRed:27.0/255 green:73.0/255 blue:97.0/255 alpha:1.0]//深 #define colorPageCu [UIColor colorWithRed:120.0/255 green:180.0/255 blue:215.0/255 alpha:1.0]//浅 #define colorTextBack [UIColor colorWithRed:214.0/255 green:214.0/255 blue:214.0/255 alpha:1.0]//浅灰色 //全部按钮的背景 #define imgBtnHighlighted [UIImage imageNamed:@"buddy_header_bg_highlighted"] //UI的圆角 #define YUANJIAO 8 //获取状态栏高度 貌似都使20 #define statusHeight [[UIApplication sharedApplication] statusBarFrame].size.height //开关 字体大小 #define switchFontSize [UIFont systemFontOfSize:14] #import "Tools.h" #import "sys/utsname.h" @implementation Tools - (void)intoFirtstVC { self.window = [[UIWindow alloc]initWithFrame:[[UIScreen mainScreen] bounds]]; ViewController *rootController = [[ViewController alloc]init]; self.window.rootViewController = rootController; self.window.backgroundColor = [UIColor whiteColor]; [self.window makeKeyAndVisible]; }
//获取当前手机型号 + (NSString *)getCurrentDeviceModel { struct utsname systemInfo; uname(&systemInfo); NSString *platform = [NSString stringWithCString:systemInfo.machine encoding:NSUTF8StringEncoding]; if ([platform isEqualToString:@"iPhone1,1"]) return @"iPhone 2G (A1203)"; if ([platform isEqualToString:@"iPhone1,2"]) return @"iPhone 3G (A1241/A1324)"; if ([platform isEqualToString:@"iPhone2,1"]) return @"iPhone 3GS (A1303/A1325)"; if ([platform isEqualToString:@"iPhone3,1"]) return @"iPhone 4 (A1332)"; if ([platform isEqualToString:@"iPhone3,2"]) return @"iPhone 4 (A1332)"; if ([platform isEqualToString:@"iPhone3,3"]) return @"iPhone 4 (A1349)"; if ([platform isEqualToString:@"iPhone4,1"]) return @"iPhone 4S (A1387/A1431)"; if ([platform isEqualToString:@"iPhone5,1"]) return @"iPhone 5 (A1428)"; if ([platform isEqualToString:@"iPhone5,2"]) return @"iPhone 5 (A1429/A1442)"; if ([platform isEqualToString:@"iPhone5,3"]) return @"iPhone 5c (A1456/A1532)"; if ([platform isEqualToString:@"iPhone5,4"]) return @"iPhone 5c (A1507/A1516/A1526/A1529)"; if ([platform isEqualToString:@"iPhone6,1"]) return @"iPhone 5s (A1453/A1533)"; if ([platform isEqualToString:@"iPhone6,2"]) return @"iPhone 5s (A1457/A1518/A1528/A1530)"; if ([platform isEqualToString:@"iPhone7,1"]) return @"iPhone 6 Plus (A1522/A1524)"; if ([platform isEqualToString:@"iPhone7,2"]) return @"iPhone 6 (A1549/A1586)"; if ([platform isEqualToString:@"iPhone8,1"]) return @"iPhone 6s Plus (A1522/A1524)"; if ([platform isEqualToString:@"iPhone8,2"]) return @"iPhone 6s (A1549/A1586)"; if ([platform isEqualToString:@"iPod1,1"]) return @"iPod Touch 1G (A1213)"; if ([platform isEqualToString:@"iPod2,1"]) return @"iPod Touch 2G (A1288)"; if ([platform isEqualToString:@"iPod3,1"]) return @"iPod Touch 3G (A1318)"; if ([platform isEqualToString:@"iPod4,1"]) return @"iPod Touch 4G (A1367)"; if ([platform isEqualToString:@"iPod5,1"]) return @"iPod Touch 5G (A1421/A1509)"; if ([platform isEqualToString:@"iPad1,1"]) return @"iPad 1G (A1219/A1337)"; if ([platform isEqualToString:@"iPad2,1"]) return @"iPad 2 (A1395)"; if ([platform isEqualToString:@"iPad2,2"]) return @"iPad 2 (A1396)"; if ([platform isEqualToString:@"iPad2,3"]) return @"iPad 2 (A1397)"; if ([platform isEqualToString:@"iPad2,4"]) return @"iPad 2 (A1395+New Chip)"; if ([platform isEqualToString:@"iPad2,5"]) return @"iPad Mini 1G (A1432)"; if ([platform isEqualToString:@"iPad2,6"]) return @"iPad Mini 1G (A1454)"; if ([platform isEqualToString:@"iPad2,7"]) return @"iPad Mini 1G (A1455)"; if ([platform isEqualToString:@"iPad3,1"]) return @"iPad 3 (A1416)"; if ([platform isEqualToString:@"iPad3,2"]) return @"iPad 3 (A1403)"; if ([platform isEqualToString:@"iPad3,3"]) return @"iPad 3 (A1430)"; if ([platform isEqualToString:@"iPad3,4"]) return @"iPad 4 (A1458)"; if ([platform isEqualToString:@"iPad3,5"]) return @"iPad 4 (A1459)"; if ([platform isEqualToString:@"iPad3,6"]) return @"iPad 4 (A1460)"; if ([platform isEqualToString:@"iPad4,1"]) return @"iPad Air (A1474)"; if ([platform isEqualToString:@"iPad4,2"]) return @"iPad Air (A1475)"; if ([platform isEqualToString:@"iPad4,3"]) return @"iPad Air (A1476)"; if ([platform isEqualToString:@"iPad4,4"]) return @"iPad Mini 2G (A1489)"; if ([platform isEqualToString:@"iPad4,5"]) return @"iPad Mini 2G (A1490)"; if ([platform isEqualToString:@"iPad4,6"]) return @"iPad Mini 2G (A1491)"; if ([platform isEqualToString:@"i386"]) return @"iPhone Simulator"; if ([platform isEqualToString:@"x86_64"]) return @"iPhone Simulator"; return platform; } @end