UIScrollView,uiscrollview使用

來源:互聯網
上載者:User

UIScrollView,uiscrollview使用

知識點:

1)UIScrollView

2)UIPageControl

======================================================

 

一、UIScrollView

 

1、UIScrollView介紹

可以滾動的視圖,一般用於相簿的瀏覽,廣告,app初次開機的引導圖,或者多屏滾動等

 

2、常用的屬性和方法

1)contentSize  捲動區域,捲動區域必須大於scrollView的寬高,才能滾動

2)showsHorizontalScrollIndicator 水平捲軸

3)showsVerticalScrollIndicator 垂直捲軸

4)directionalLockEnabled  鎖定方法

5)scrollsToTop  點擊狀態列時自動滑動到頂部

6)pagingEnabled  每次滑動一屏

7)bounces  拽拖邊界

8)delegate  代理

9)contentOffset  位移量,用來判斷滾動到第幾屏

 

當有導航時,需要使用automaticallyAdjustsScrollViewInsets調整ScrollView的捲動區域,當為NO時,ScrollView是從螢幕的最上邊開始,也就是被狀態列和導覽列所覆蓋;當為YES時,也就是預設行為,當上下滑動時,是可以穿透導覽列和狀態列的。 

和edgesForExtendedLayout的區別可以穿透導覽列和狀態列

(關於這兩個的區別在前面的一篇部落格中有詳細說明)

 

3.UIScrollView的代理

// 只要scrollView滑動過程就會被調用

- (void)scrollViewDidScroll:(UIScrollView *)scrollView

//scrollView開始拖拽時調用

- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView

// 停止減速時被調用

- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView

還有很多,大家自己看下

 

4.有時會配合定時器一起使用,讓scrollView自動輪播

======================================================

 

二、UIPageControl

 

1、UIPageControl介紹

分頁指標,一般與ScrollView配合使用

 

2、常用屬性和方法

1)numberOfPages  指示點的個數

2)currentPage  設定預設第幾個點被選中

3)hidesForSinglePage  當只有一個點時隱藏該控制項

4)pageIndicatorTintColor  所有點的顏色

5)currentPageIndicatorTintColor  當前點的顏色

相關文章

聯繫我們

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