• Srilalitha

iOS UI scroll view animation effects


iOS (formerly iPhone OS) is a mobile operating system created and developed by Apple Inc. exclusively for its hardware. It is the operating system that powers many of the company's mobile devices, including the iPhone and iPod Touch; it also powered the iPad until the introduction of iPadOS in 2019. It is the world's second-most widely installed mobile operating system, after Android. It is the basis for three other operating systems made by Apple: iPadOS, tvOS, and watchOS.


Unveiled in 2007 for the first-generation iPhone, iOS has since been extended to support other Apple devices such as the iPod Touch (September 2007) and the iPad (January 2010). As of March 2018, Apple's App Store contains more than 2.1 million iOS applications, 1 million of which are native for iPads.


How does the iOS work?


Apple's iOS lets you interact with all of the applications on your iPhone. It displays icons for each application on the iPhone's screen. It also manages battery power and system security. ... But instead of using a mouse or a physical keyboard, the iPhone uses virtual buttons and controls that appear on its screen.


Who created the iOS?


Steve Jobs

In what is widely regarded as his greatest presentation ever, Apple's Steve Jobs introduced the iPhone to the world on January 9th, 2007. In the five-plus years since then, the iPhone, iPad, and iPod Touch have literally redefined the entire world of mobile computing.


What is a scroll view?


In android, ScrollView is a kind of layout that is useful to add vertical or horizontal scroll bars to the content which is larger than the actual size of layouts such as linearlayout, relativelayout, framelayout, etc. In android, ScrollView supports only vertical scrolling.


UI Scroll View.


A view that allows the scrolling and zooming of its contained views


In iOS, scroll views are used to view content that won’t fit entirely on the screen. Scroll views have two main purposes:


· To let users drag the area of the content they want to display

· To let users zoom in to or out of the displayed content using the pinch gestures


A common control used in iOS apps – UITableView – is a subclass of UIScrollView and provides a great way to view content that is larger than the screen.


In iOS, scroll views are used to view content that won't fit entirely on the screen. Scroll views have two main purposes: To let users drag the area of the content they want to display. To let users zoom in to or out of the displayed content using the pinch gestures.


iOS uses motion effects, such as a parallax effect, to create the perception of depth on the Home screen and in other areas. These effects can increase understanding and enjoyment, but overusing them can make an app feel disorienting and difficult to control.


How do you animate on iOS?


Animate an object


1. Tap the object that you want to animate, then tap Animate in the menu that appears.

2. Tap Add Action, then choose an animation.

3. Tap Done in the upper-right corner. You can customize an animation at any time.


UIScrollView in iOS


UIScrollView is an old and versatile class in UIKit, and has been around since iOS was iPhone OS 2.0. It Provides flexibility to present large content which doesn’t fit into the device screens. The most popular UIComponents in iOS (UITextView, UITableView & UICollectionView) are inherited from the UIScrollView class.


→ UIScrollView has 3 main properties, known as contentSize, contentOffset, and contentInset.


→ Content-Size :


ScrollViews offer a lot of power to developers with a little setup and code. All the heavy peace of work is handled by Apple, and Developers were given a well known delegate(UIScrollViewDelegate) to manage its states and functionality. A ScrollView is just a UIView object, which has dynamic origin and moves its content around. it has an important property called, contentSize, of type CGSize, which represents the size of the scrollable area. The scroll view must know the size of the content-view so it knows when to stop scrolling. its default value is zero, and it must be set to use any scroll view, even if the content-size is smaller than the scroll view’s own size.


In the above image, The actual frame of the scroll-View is represented by black thick lines and the content size is the size of the boy’s image.


→ Content-Offset :


When the user scrolls the scroll view, the content area visible to the user changes. The position of the content view within the scroll view is called the content offset and is represented by the contentOffset property, a CGPoint value. This property is defined by the distance with x and y values from the visible region’s origin(top-left point) to the content view’s origin(have a look on the following image). The content size remains the same, but the content offset changes to respond to user interaction.


Content offset can be changed programmatically. The contentOffset property is readwrite. More interestingly, you can use the func setContentOffset(CGPoint, animated: Bool)method to animate the change in content offset. This “moves” the scroll view, just as it would if the user moved it himself.


→ Content-Inset :


This is a UIEdgeInset value that represents the area around the scroll view’s content that it should “pad”. Setting the contentInset property to UIEdgeInsetsMake(10, 10, 10, 10) would create a 10-point margin surrounding the scroll view’s content. The edge inset values can also be negative; this would represent area around the scroll view content that can’t be seen by the user (unless user scrolls past the edge of the scroll view).


→ There are 3 groups of methods in UIScrollViewDelegate, those respond to dragging & scrolling, zooming and scrolling animations.


1. Scrolling and Dragging :


Tells the delegate when the user scrolls the content view within the receiver. Calls whenever the content offset of the scroll view changes, either programmatically or in response to user interaction. Possible use could be in a custom pull-to-refresh control.


Calls whenever the scrollView is about to be dragged by the user. Possible use could be disabling the updates to the scrollView that might interrupt the smoothness of scrolling.


Calls whenever the user has lifted his finger from the scroll view after dragging. The second parameter specifies a speed, in points/second, that the scroll view has at the moment the user lifts his finger. The third parameter is a pointer to a CGPoint, representing where the scroll view will scroll. Modifying the CGPoint at that pointer changes where the scroll view scrolls to. Possible use could be calculating what content is going to be visible when the scrolling animation ends and prefetching it from an application programming interface (API).


Calls whenever the user has lifted his finger from the scroll view after dragging. The second parameter specifies whether the scroll view animates its deceleration to come to a stop or if it was already stopped when the user lifted his finger. Possible use includes restarting any paused computations halted in scrollView Will Begin Dragging: as long as the second parameter is NO.


Asks the delegate if the scroll view should scroll to the top of the content.


Tells the delegate that the scroll view scrolled to the top of the content.


Tells the delegate that the scroll view is starting to decelerate the scrolling movement. Called whenever the scroll view is about to begin a decelerating animation.


Tells the delegate that the scroll view has ended decelerating the scrolling movement. Calls after the scroll view’s deceleration animation completes. Possible use includes restarting any paused computations halted in scrollViewWillBeginDragging


2. Zooming :


Asks the delegate for the view to scale when zooming is about to occur in the scroll view.


Tells the delegate that zooming of the content in the scroll view is about to commence.


Tells the delegate when zooming of the content in the scroll view completed.


Tells the delegate that the scroll view’s zoom factor changed.


3. Scrolling Animation :


Tells the delegate when a scrolling animation in the scroll view concludes.


Responding to Inset Changes :


Called when the scroll view’s inset values changed.


Srilalitha

cc@p66.me

www.p66.me

-------------------------------------------------------------------------------------------------------------------------------

Disclaimer: The content on this site belongs to its respective owners. We don’t have any claims on images or content. The intention of this blog is Public Awareness / Knowledge base and providing insight to readers.

Insight:

About p66www.p66.me

Headquarters in Newark, DE, United States of America. And having a production facility in Bangalore, Karnataka, India. P66 is one of the best 2D & 3D Production mushroom sized Creative Agency. Aiming to provide best creative services at a very affordable cost. P66 is a studio which is specialised in Traditional & Digital Type of Animation. It has provided contribution in the areas of 2D Animation, 3D Animation, Motion Graphics, Free-hand drawing, Drawing & Illustration, Digital Comic Books, Digital 2D Painting, Concept Artistry Drawing, 2D & 3D Game Designing, E-learning for kids

To provide a FREE Consultation about services of P66 do reach us on +1 (914) 247-7791 or Email us on :Reply@p66.me

-------------------------------------------------------------------------------------------------------------------------------

9 views

Email: Reply@p66.me | Phone: +1(914)-247-7791