How to use Uiscrollview

Source: Internet
Author: User

Create Secroll View

Uiscrollview _scrollview = [[Uiscrollviewalloc]initwithframe:cgrectzero];

_scrollview.scrollenabled =yes;//settings can be pulled

_scrollview.backgroundcolor=[uicolorredcolor];//Set Background color

_scrollview.frame =cgrectmake (0,34, ScreenWidth, screenheight-self.tabbarcontroller.tabbar.frame.size.height); Set Location

[_scrollview addsubview:_tempview];//Add view

Calculate scroll View Size

_scrollview.contentsize=cgsizemake (300,_tempview.frame.origin.y+_tempview.frame.size.height);

Other properties

Indicates whether a rebound is possible when the boundary is exceeded

_scrollview.bounces=yes;

Whether paging

_scrollview.pagingenabled=yes;

Whether to scroll

_scrollview.scrollenabled=yes;

Whether to show boundaries

_scrollview.showshorizontalscrollindicator=yes;

Set the indicator style

_scrollview.indicatorstyle=uiscrollviewindicatorstylewhite;


Attribute description

Tracking
When the touch has not been dragged when the value is yes, otherwise no

Zoombouncing
The value is yes when the content is enlarged to the maximum or least, otherwise NO

Zooming
The value is yes when zooming, otherwise NO

decelerating
When scrolling, the finger is released but continues to scroll. This time is yes, other times is NO

Decelerationrate
Set the deceleration rate after finger release

Maximumzoomscale
A floating-point number that represents the maximum multiplier

Minimumzoomscale
A floating-point number that represents the minimum number of times that can be shrunk.

Pagingenabled
Yes will automatically scroll to the bounds of the subview. Default is No

Scrollenabled
Decide whether you can scroll

Delayscontenttouches
is a Boolean, when the value is yes, the user touches the start, scroll view to delay a moment to see if the user has intent to scroll. If scrolling, then catch Touch-down event, otherwise it will not capture. If the value is no, when the user touches, scroll view immediately triggers the TouchesShouldBegin:withEvent:inContentView: Yes, by default

Cancancelcontenttouches
When the value is yes, the user touches and then does not move within a certain period of time, ScrollView sends tracking events, then the user moves the finger enough to trigger the scrolling event, which ScrollView sends touchescancelled: Withevent: To Subview, then scroview to start scrolling. If the value is No,scrollview send tracking events, even if the user moves the finger, ScrollView will not scroll.

Contentsize
Inside the size of the content, that is, can scroll the size, the default is 0, no scrolling effect.

Showshorizontalscrollindicator
Whether to display a horizontal scroll bar when scrolling

Showsverticalscrollindicator
Whether to display a vertical scroll bar when scrolling

Bounces
The default is yes, or scrolling over the border will bounce back with the effect. If it is NO, then scrolling to the boundary will stop at once.

Bounceszoom
Similar to bounces, the difference is that this effect is reflected in the zoom, if the zoom exceeds the maximum zoom, then the rebound effect, if NO, the maximum or smallest time to stop immediately.

Directionallockenabled
The default is NO, which you can move in both vertical and horizontal directions. If the value is yes, if the first is vertical or horizontal movement, then the next one will lock the scroll in the other direction. If you start out in a diagonal direction, you won't block a direction

Indicatorstyle
Scroll bar style, basically just set the color. Total 3 colors: default, Black, white

Scrollindicatorinsets
Set the position of the scroll bar

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.