UIScrollView --scrollRectToVisible:animated:方法

該方法在官方的解釋是這樣的

Scrolls a specific area of the content so that it is visible in the receiver.

Declaration
SWIFT  :  func scrollRectToVisible(_ rect: CGRect ,
                       animated animated : Bool)

OBJECTIVE-C : 
- (void)scrollRectToVisible:(CGRect)rect
                   animated:(BOOL)animated

Parameters
rect      A rectangle defining an area of the content view. The rectangle should be in the coordinate space of the scroll view.

animated      YES (if the scrolling should be animated.), NO (if it should be immediate.)

Discussion
This method scrolls the content view so that the area defined by  rect is just visible inside the scroll view. If the area is already visible, the method does nothing.

Availability
Available in iOS 2.0 and later.

使用這個(gè)方法可以將滾動(dòng)到特定的區(qū)域,讓視圖可見(jiàn)。
rect的作用是定義要可見(jiàn)視圖的區(qū)域,這個(gè)區(qū)域需要在滾動(dòng)視圖的坐標(biāo)空間中。animated就不需要多解釋了。
還有一點(diǎn)需要注意的是該可見(jiàn)視圖是在這個(gè)滾動(dòng)視圖的范圍而當(dāng)前不可見(jiàn),如果當(dāng)前已經(jīng)可見(jiàn)了,那么這個(gè)方法將不會(huì)做任何事情。

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容