iphone - make UIView in UIScrollView stick to the top when scrolled up -
so in uitableview when have sections section view sticks top until next section overlaps , replaces on top. want have similar effect, have uiview in uiscrollview, representing sections uiview , when hits top.. want stay in there , not carried up. how do this? think needs done in either layoutsubviews or scrollviewdidscroll , manipulation on uiview..
to create uiview in uiscrollview stick top when scrolled do:
- (void)createheaderview:(uiview*)headerview { _headerview = [headerview retain]; _headerviewinitialy = _headerview.frame.origin.y; [_scrollview addsubview:_headerview]; _scrollview.delegate = self; } - (void)scrollviewdidscroll:(uiscrollview *)scrollview { cgrect headerframe = _headerview.frame; headerframe.origin.y = max(_headerviewinitialy, scrollview.contentoffset.y); _headerview.frame = headerframe; }
Comments
Post a Comment