ios - Make Top image in UIScrollView enlarge on scroll view bounds? -
i have uiscroll view uiview inside content view. layout is:
self.scrollview = uiscrollview() self.view.addsubview(self.scrollview) self.scrollview.backgroundcolor = uicolor.yellowcolor() // pin edges edges of superview (self.view) self.scrollview.snp_makeconstraints { (make) -> void in make.edges.equalto(self.view) } // create contentview self.contentview = uiview() self.contentview.backgroundcolor = uicolor.redcolor() self.scrollview.addsubview(self.contentview) // pin edges of contentview scrollview self.contentview.snp_makeconstraints { (make) -> void in make.edges.equalto(self.scrollview) }
in contentview have uiimageview @ top , uilabels below:
let imageview = uiimageview(...) let labe1 = uilabel(...) let labe2 = uilabel(...) self.contentview.addsubview(imageview) self.contentview.addsubview(labe1) self.contentview.addsubview(labe2)
here how looks like:
when pull down scroll view scroll view bounces @ top. want image enlarges when scroll view bounces.
i did uiscrollviewdelegate
:
func scrollviewdidscroll(scrollview: uiscrollview) { let offsety: cgfloat = scrollview.contentoffset.y if offsety < -64 { let progress:cgfloat = fabs(offsety + 64) / 100 self.imageview.transform = cgaffinetransformmakescale(1 + progress, 1 + progress) } }
this works problem when image transformed should not overlay border red area contains labels. here happens when bounce:
i want image still enlarges not overlapping border red area. how can that?
i suggest resize whole uiscrollview
pager view - don't forget reset its's frame prevent wrong paging.
Comments
Post a Comment