IOS開發基礎知識--片段7

來源:互聯網
上載者:User

標籤:

三十八:各個版本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

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.