標籤:
三十八:各個版本IPHONE解析度及圖片的實現原理
[email protected] : iPhone 4s (320 x 420)desert[email protected] : iPhones 5, 5C and 5S (320 x 568)desert[email protected] : iPhone 6 (375 x 667)desert[email protected] : iPhone 6+ (414 x 736)[email protected]~ipad : iPad (1024 x 768)
介面大小比例:
圖片大小實現的原理:
#import <UIKit/UIKit.h>typedef NS_ENUM(NSInteger, thisDeviceClass) { thisDeviceClass_iPhone, thisDeviceClass_iPhoneRetina, thisDeviceClass_iPhone5, thisDeviceClass_iPhone6, thisDeviceClass_iPhone6plus, // we can add new devices when we become aware of them thisDeviceClass_iPad, thisDeviceClass_iPadRetina, thisDeviceClass_unknown};thisDeviceClass currentDeviceClass();@interface UIImage (DeviceSpecificMedia)+ (instancetype )imageForDeviceWithName:(NSString *)fileName;@end
#import "UIImage+DeviceSpecificMedia.h"thisDeviceClass currentDeviceClass() { CGFloat greaterPixelDimension = (CGFloat) fmaxf(((float)[[UIScreen mainScreen]bounds].size.height), ((float)[[UIScreen mainScreen]bounds].size.width)); switch ((NSInteger)greaterPixelDimension) { case 480: return (( [[UIScreen mainScreen]scale] > 1.0) ? thisDeviceClass_iPhoneRetina : thisDeviceClass_iPhone ); break; case 568: return thisDeviceClass_iPhone5; break; case 667: return thisDeviceClass_iPhone6; break; case 736: return thisDeviceClass_iPhone6plus; break; case 1024: return (( [[UIScreen mainScreen]scale] > 1.0) ? thisDeviceClass_iPadRetina : thisDeviceClass_iPad ); break; default: return thisDeviceClass_unknown; break; }}@implementation UIImage (deviceSpecificMedia)+ (NSString *)magicSuffixForDevice{ switch (currentDeviceClass()) { case thisDeviceClass_iPhone: return @""; break; case thisDeviceClass_iPhoneRetina: return @"@2x"; break; case thisDeviceClass_iPhone5: return @"[email protected]"; break; case thisDeviceClass_iPhone6: return @"[email protected]"; //or some other arbitrary string.. break; case thisDeviceClass_iPhone6plus: return @"[email protected]"; break; case thisDeviceClass_iPad: return @"~ipad"; break; case thisDeviceClass_iPadRetina: return @"[email protected]"; break; case thisDeviceClass_unknown: default: return @""; break; }}+ (instancetype )imageForDeviceWithName:(NSString *)fileName{ UIImage *result = nil; NSString *nameWithSuffix = [fileName stringByAppendingString:[UIImage magicSuffixForDevice]]; result = [UIImage imageNamed:nameWithSuffix]; if (!result) { result = [UIImage imageNamed:fileName]; } return result;}@end
三十九:其它幾張知識圖片
1:NSObject繼承類圖
2:sqlite3返回含義
3:視圖座標說明
4:生命週期圖
5:UI繼承圖
6:Segue略過清單,關於selection跟Accessory的區別
IOS開發基礎知識--片段7