偷偷摘套内射激情视频,久久精品99国产国产精,中文字幕无线乱码人妻,中文在线中文a,性爽19p

iOS開(kāi)發(fā)之適配iphone5

移動(dòng)開(kāi)發(fā) iOS
iphone5的屏幕分辨率:1136 x 640 也即是高度變成了568,程序啟動(dòng)時(shí)我們需要一張retina圖片命名為Default-568h@2x.png。在我們創(chuàng)建工程時(shí)xcode會(huì)默認(rèn)為我們創(chuàng)建一個(gè)純黑色的圖片替換即可。最新版的xcode都已支持iphone5調(diào)試:選中模擬器---->設(shè)備---->iphone(Retina 4-inch),稍等片刻就可以切換到iphone5模擬器。

隨著iphone5普及度增高,從不用適配的我們也要像android一樣適配不同分辨率的屏幕了。

公司產(chǎn)品新版本需要適配iphone5,經(jīng)過(guò)一番折騰算是搞定了。下面分享給大家:

iphone5的屏幕分辨率:1136 x 640 也即是高度變成了568,程序啟動(dòng)時(shí)我們需要一張retina圖片命名為Default-568h@2x.png。在我們創(chuàng)建工程時(shí)xcode會(huì)默認(rèn)為我們創(chuàng)建一個(gè)純黑色的圖片替換即可。

最新版的xcode都已支持iphone5調(diào)試:選中模擬器---->設(shè)備---->iphone(Retina 4-inch),稍等片刻就可以切換到iphone5模擬器。

要適配iphone5需要將view的autosizing設(shè)置為如下?tīng)顟B(tài):

\

當(dāng)然還要確認(rèn)選中另一項(xiàng)

\

這一項(xiàng)默認(rèn)會(huì)選中的,意思是自動(dòng)縮放子視圖。

如果我們的view沒(méi)有使用xib那我們可以使用代碼設(shè)置這些屬性:

  1. [cpp]  
  2.  
  3. self.view.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleTopMargin    
  4.  
  5. | UIViewAutoresizingFlexibleRightMargin |  UIViewAutoresizingFlexibleBottomMargin     
  6.  
  7. | UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;   
  8.  
  9. self.view.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleTopMargin  
  10.  
  11. | UIViewAutoresizingFlexibleRightMargin |  UIViewAutoresizingFlexibleBottomMargin   
  12.  
  13. | UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth; 

接下來(lái)設(shè)置子視圖(比如button,image等):

\

對(duì)應(yīng)代碼:

  1. [cpp]  
  2.  
  3. autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleTopMargin;   
  4.  
  5. .autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleTopMargin; 

意思是將控件縮放時(shí)與父視圖左邊和頂部對(duì)應(yīng)??梢愿鶕?jù)具體需要設(shè)置子控件的autorizingMask相應(yīng)值。

我們還可以通過(guò)代碼手動(dòng)改變iphone5下控件的大小或位置:

首先判定一下設(shè)備是否為iphone5:

  1. [cpp]  
  2.  
  3. #define DEVICE_IS_IPHONE5 ([[UIScreen mainScreen] bounds].size.height == 568)    
  4.  
  5. #define DEVICE_IS_IPHONE5 ([[UIScreen mainScreen] bounds].size.height == 568) 接著我們可以在view初始化的時(shí)候改變frame: 
  6.  
  7. [cpp]  
  8.  
  9. if (DEVICE_IS_IPHONE5) {   
  10.  
  11.         [botton setFrame:CGRectMake(0, 450, 320, 440)];   
  12.  
  13. }   
  14.  
  15. if (DEVICE_IS_IPHONE5) { 
  16.  
  17.         [botton setFrame:CGRectMake(0, 450, 320, 440)]; 
責(zé)任編輯:閆佳明 來(lái)源: cnblogs
相關(guān)推薦

2013-03-22 13:10:20

3GS蘋(píng)果移動(dòng)應(yīng)用

2011-07-13 09:32:05

蘋(píng)果iOS 5

2011-10-05 03:37:59

iPhone5iPhone 4S蘋(píng)果

2012-05-11 17:45:26

iPhone5概念機(jī)電腦管家安全

2013-04-16 16:01:51

APP支持iPhoneiOS開(kāi)發(fā)

2013-04-09 10:35:01

2012-10-09 15:28:06

2012-09-19 10:25:56

iPhone 5游戲開(kāi)發(fā)者

2018-01-16 15:06:36

iPhone XiOS

2013-07-31 11:06:26

青蘋(píng)果夏威夷版iPhoiPhone5定制版

2012-03-11 15:23:01

iPhone

2011-08-05 11:04:27

iOS 5蘋(píng)果

2012-09-19 09:54:52

iOS開(kāi)發(fā)者iPhone 5

2011-03-29 09:14:46

WWDC蘋(píng)果iPhone

2012-06-21 09:41:34

郭臺(tái)銘iPhone 5

2012-09-20 14:22:34

2011-10-11 10:22:54

iPhone5蘋(píng)果

2011-07-08 14:58:16

iPhone Xcode iOS

2011-08-02 13:35:41

iOS開(kāi)發(fā) Get Post

2013-09-12 10:11:57

蘋(píng)果iPhone 5ciPhone 5s
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號(hào)