How to display a UIView when it overlaps another iOS? -
i trying re-implement similar apple watch friend picker. have 2 uiviews, both corner radius of half height appear circles. how calculate overlap , show part. ui in first picture , second 1 contains desired behavior. in advance help?
for each of circles initials, can have top view--the unselected state--and bottom view--the selected state. have movable view in shape of circle tracks tip of point. when view intersects of outer circle create mask equal rounded bounds of invisible view.
for example:
if cgrectintersectsrect(self.movableview.frame, self.topview.frame) { self.topview.layer.mask = nil let shapelayer = cashapelayer() let rect = self.topview.convertrect(self.movableview.bounds, fromview: self.movableview) let path = uibezierpath(ovalinrect: rect) let maskpath = cgpathcreatemutable() cgpathaddrect(maskpath, nil, self.view.frame) cgpathaddpath(maskpath, nil, path.cgpath) shapelayer.path = maskpath shapelayer.fillrule = kcafillruleevenodd self.topview.layer.mask = shapelayer }
to avoid excessive hit detection should keep track of selected view , check intersection view preceding selected view, selected view, , view following selected view. i've created rudimentary example of masking if you're interested.
Comments
Post a Comment