TBXark / PinterestSegment

A Pinterest-like segment control with masking animation.
http://tbxark.com/2016/12/08/2016-12-08-Swift-Pinterst/
MIT License
687 stars 56 forks source link

Move Segments to horizontally Center #6

Open gerryats opened 6 years ago

gerryats commented 6 years ago

How can I move segments to horizontal center of screen. Suppose if their are 2 segments only?

TBXark commented 6 years ago

Rewrite func reloadData(), Set scrollView. contentInset based on the frame value of titleLabels.last

jalakoo commented 6 years ago

I was unsuccessful in centering content with the above instructions. What I tried:

        // Center
        if let lastFrame = titleLabels.last?.frame {
            scrollView.contentInset = UIEdgeInsetsMake(lastFrame.origin.x,
                                                       lastFrame.origin.y,
                                                       lastFrame.height,
                                                       lastFrame.width)
        }