ios基礎知識--03

來源:互聯網
上載者:User

標籤:

裝置

螢幕類型

螢幕尺寸

解析度(像素)

iPhone 3GS

非Retina

3.5 inch

320*480

320x480

iPhone4\4S

Retina

3.5 inch

320*480

640x960

iPhone5\5C\5S

Retina

4 inch

320*568

640x1136

iPhone6

Retina

4.7 inch

375*667

750x1334

iPhone6 Plus

Retina

5.5 inch

414*736

1242x2208

在retina螢幕下一個點表示2個像素,在非retina螢幕下一個點表示1個像素。在iphone6 plus 下一個點表示3個像素。

 

?  結論1:在同樣一個尺寸的螢幕下由於使用的螢幕不一樣(retina和非retina),所以造成的螢幕解析度會不同。也就是說,同樣是30*30的像素,在3.5 inch大小的螢幕上,如果是非retina顯示會大一些, retina螢幕顯示會小一些。

?  結論2:所以在開發中使用的是點。(比如使用30*30,不是表示30像素,而是表示30點,這樣的話iOS系統會自動把點轉換為對應的像素)。

?      1>非retina螢幕1個點表示1像素

?      2> retian螢幕1個點表示2像素

?      3> iPhone6 Plus下1個點表示3像素

?  結論3:因為程式中的是點, iOS系統會自動把點轉換為不同的像素去找圖片,所以圖片對應的也要準備多份不同的圖片。

?  @2x (視網膜螢幕,在原來點座標的大小上乘以2)

?  @3x

?  比如:btn_left這張圖,在代碼中寫的時候使用的是btn_left,iOS會根據實際的螢幕去尋找btn_left.png或者是[email protected]或者[email protected]

?  [email protected]

?      568表示iPhone5

?      h表示高度

?      上面的這些都是固定寫法,順序不能調換

總結:iOS開發面向的是點座標系,不是像素

?  一個app在啟動過程中會全螢幕顯示叫做Default.png的圖片

?  不用規格Default的使用場合

?  Default.png:非retina-iPhone螢幕(3.5 inch),320x480

?  [email protected]:retina-iPhone螢幕(3.5 inch),640x960

?  [email protected]:4 inch的retina-iPhone螢幕,640x1136

?  Default-Portrait~ipad.png:非retain-iPad豎屏螢幕,768x1024

?  [email protected]:retain-iPad豎屏螢幕,1536x2048

?  Default-Landscape~ipad.png:非retain-iPad橫屏螢幕,1024x768

?  [email protected]:retain-iPad橫屏螢幕,2048x1536

 

應用程式圖示:

?  只要檔案名稱叫做Icon.png,就會自動被當做是應用程式的表徵圖

?  一個應用程式可以準備多種規格的表徵圖,詳情可以查看蘋果官方文檔,如右圖

 

 

 

啟動圖片:

1.LaunchScreen

2.launch image souce

 

 

UIButton:

?  UIButton有很多種狀態,它提供了一些便捷屬性,可以直接擷取目前狀態下的文字、文字顏色、圖片等

?  @property(nonatomic,readonly,retain)NSString *currentTitle;

?  @property(nonatomic,readonly,retain)UIColor  *currentTitleColor;       

?  @property(nonatomic,readonly,retain)UIImage  *currentImage;            

?  @property(nonatomic,readonly,retain)UIImage  *currentBackgroundImage;

 

 

 

 

 

狀態列:

?  在iOS7中,狀態列預設情況下歸控制器管理,比如狀態列的樣式、狀態列的是否可見

?  控制器通過重寫以下方法來控制狀態列

?  設定狀態列的樣式

-  (UIStatusBarStyle)preferredStatusBarStyle;

其中UIStatusBarStyleLightContent是白色樣式

?  設定狀態列的可見度

-(BOOL)prefersStatusBarHidden;

 

:-(UIStatusBarStyle)preferredStatusBarStyle{

    return  UIStatusBarStyleLightContent;

}

 

- (BOOL) prefersStatusBarHidden{

    return YES;

   

 

}

 

 

 

1. 將圖片移動到視圖的頂層

//bringSubviewToFront 調用方法的這個view,必須是被攜帶view的父view

[self.viewbringSubviewToFront:self.imageView]

 

 

//userInteractionEnabled = NO 禁止任何使用者互動,如果是父view設定了這個屬性為no,那麼它的子view也將不會接受使用者互動

 

使用kvc的方式賦值:

[self setValuesForKeyWithDictionary:dict];

 

    //讓數組中所有元素都執行 removeFromSuperview

    [_answerView.subviewsmakeObjectsPerformSelector:@selector(removeFromSuperview)];

 

//遍曆數組(最快的):

   [_optionView.subviews enumerateObjectsUsingBlock:^(__kindof UIView *_Nonnull obj, NSUIntegeridx, BOOL * _Nonnull stop) {

obj 數組中的對象;

idx 表示下標;

*stop yes 立即跳出遍曆;

        }

    }];

ios基礎知識--03

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.