Skip to content

How to use in the ScrollView? #19

@BadDeveloper2022

Description

@BadDeveloper2022

How to use in the ScrollView?

`let horizontalScrollView:ASHorizontalScrollView = ASHorizontalScrollView(frame:CGRect(x: 0, y: Y, width:ScreenWidth, height: 50))
//for iPhone 5s and lower versions in portrait
horizontalScrollView.marginSettings_320 = MarginSettings(leftMargin: 10, miniMarginBetweenItems: 5, miniAppearWidthOfLastItem: 20)
//for iPhone 4s and lower versions in landscape
horizontalScrollView.marginSettings_480 = MarginSettings(leftMargin: 10, miniMarginBetweenItems: 5, miniAppearWidthOfLastItem: 20)
// for iPhone 6 plus and 6s plus in portrait
horizontalScrollView.marginSettings_414 = MarginSettings(leftMargin: 10, miniMarginBetweenItems: 5, miniAppearWidthOfLastItem: 20)
// for iPhone 6 plus and 6s plus in landscape
horizontalScrollView.marginSettings_736 = MarginSettings(leftMargin: 10, miniMarginBetweenItems: 10, miniAppearWidthOfLastItem: 30)
//for all other screen sizes that doesn't set here, it would use defaultMarginSettings instead
horizontalScrollView.defaultMarginSettings = MarginSettings(leftMargin: 10, miniMarginBetweenItems: 10, miniAppearWidthOfLastItem: 20)
horizontalScrollView.uniformItemSize = CGSize(width: 80, height: 50)

    //this must be called after changing any size or margin property of this class to get acurrate margin
    tab1.addSubview(horizontalScrollView)
 
    for _ in 1...20{
        let button = UIButton(frame: CGRect.zero)
        button.backgroundColor = UIColor.purple
        horizontalScrollView.addItem(button)
    }
       horizontalScrollView.setItemsMarginOnce()
    horizontalScrollView.refreshSubView()
    
    scroolview.addSubview(tab1)`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions