Tutorial by Examples

Create an instance of UIScrollView with a CGRect as frame. Swift let scrollview = UIScrollView.init(frame: CGRect(x: 0, y: 0, width: 320, height: 400)) Objective-C UIScrollView *scrollview = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, 320, 400)];
The contentSize property must be set to the size of the scrollable content. This specifies the size of the scrollable area. Scrolling is visible when scrollable area i.e. contentSize is larger than the UIScrollView frame size. With Autolayout: When the scroll view's content is set up using autolay...
Simple steps to use scrollview with autolayout. Create a new project with single view application Select the default viewcontroller and change its screen size to iPhone-4inch from attributes inspector. Add a scrollview to your viewcontroller's view as follows and set background color to blue ...
This project is a self-contained example done completely in the Interface Builder. You should be able to work through it in 10 minutes or less. Then you can apply the concepts you learned to your own project. Here I just use UIViews but they can represent whatever view you like (ie, button, label...
Property scrollEnabled stores a Boolean value that determines whether scrolling is enabled or not. If the value of this property is true/YES, scrolling is enabled, otherwise not.The default value is true Swift scrollview.isScrollEnabled = true Objective-C scrollview.scrollEnabled = YES;
Create UIScrollView instance let scrollview = UIScrollView.init(frame: self.view.bounds) And then set these properties: scrollView.minimumZoomScale = 0.1 scrollView.maximumZoomScale = 4.0 scrollView.zoomScale = 1.0 scrollview.delegate = self as? UIScrollViewDelegate To zoom in and out im...
scrollViewDidEndDecelerating: this tells the delegate that the scroll view has ended decelerating the scrolling movement. Objective C: - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView { [self stoppedScrolling]; } - (void)scrollViewDidEndDragging:(UIScrollView *)scrollView w...
You can restrict the directions the user is able to scroll to using the following code: func scrollViewDidScroll(_ scrollView: UIScrollView) { if scrollView.contentOffset.x != 0 { scrollView.contentOffset.x = 0 } } Every time the user scrolls on the x-axis, the scrollView's c...

Page 1 of 1