ios - Moving CALayer's mask on scroll in a Scrollview -


i experimenting ios sdk , have following uiview structure:

  • uiview
    • uiimageview - background image
    • uiimageview (with calayer mask)
    • uiscrollview
      • label

very simple structure, uiscrollview transparent layer , second uiimageview has mask on it. trying calayer mask move it's position according position of content in scroll view. if user scrolls, mask's position should updated. solved problem using uiscrollview's delegate:

- (void)scrollviewdidscroll:(uiscrollview *)scrollview {     cgpoint contentoffset = scrollview.contentoffset;     contentoffset.y = -contentoffset.y;      self.overlayimageview.viewlayer.mask.position = contentoffset; } 

mask created in viewdidload , not change during view controller's lifecycle.

the problem mask position updating slow. way looks mask following scroll view's content, not scrolling it. scrollviewdidscroll delegate method called correctly.

for better understand problem, attaching video made in ios simulator. http://www.youtube.com/watch?v=w3xrl3ltngy

so question is:

is there way make mask updating faster or limit of ios?

calayer implicit animated properties position try disable them:

- (void)scrollviewdidscroll:(uiscrollview *)scrollview {  [catransaction begin];     [catransaction setvalue:(id)kcfbooleantrue forkey:kcatransactiondisableactions]; cgpoint contentoffset = scrollview.contentoffset; contentoffset.y = -contentoffset.y;  self.overlayimageview.viewlayer.mask.position = contentoffset; [catransaction commit];  } 

Comments