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.

使用这个方法可以将滚动到特定的区域,让视图可见。
rect的作用是定义要可见视图的区域,这个区域需要在滚动视图的坐标空间中。animated就不需要多解释了。
还有一点需要注意的是该可见视图是在这个滚动视图的范围而当前不可见,如果当前已经可见了,那么这个方法将不会做任何事情。

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容