2016-08-23 55 views
1

例如,將iPhone 5的對圖像1和iPhone 6圖像2背景的背景,併爲iPhone 6+第三不同的圖像是否可以爲每個ios設備定義不同的背景圖像?

我怎樣才能做到這一點使用Interface Builder

+0

的http:// STAC koverflow.com/q/26028918/3141234 – Alexander

+0

@AlexanderMomchliov感謝您的鏈接。你會知道是否可以使用xcode中的'Size Classes'設置不同的背景圖片? – Suhaib

+0

大小類並不是要根據您的問題描述來區分設備。如果你在上下文中使用它們,它只會將iPhone與iPad區分開來。 – Aaron

回答

0

編程,你可以做這樣的事情(假定人像只):

enum Device { 

    case iPhone5 
    case iPhone6 
    case iPhone6P 

    static var sizeClass: Device { 

     let screenWidth = UIScreen.mainScreen().bounds.width 

     switch screenWidth { 
     case _ where screenWidth < 375: 
      return .iPhone5 
     case 414: 
      return iPhone6P 
     default: 
      return .iPhone6 
     } 
    } 
} 

然後你設置圖像:

switch Device.sizeClass { 
    case .iPhone5: 
     // set image 
    case .iPhone6: 
     // set image 
    case .iPhone6P: 
     // set image 
    } 
+0

不處理旋轉。 – Abizern

+0

它爲什麼不處理旋轉? – Aaron

+0

,因爲橫幅中的iPhone 5s寬於375點。 – Abizern

相關問題