mrackwitz / MRProgress

Collection of iOS drop-in components to visualize progress
MIT License
2.55k stars 305 forks source link

Masking a cell #68

Closed yasirmturk closed 9 years ago

yasirmturk commented 10 years ago

can u do it like there are 2 areas

  1. background which masks the view under and do it translucent or blur whatever, this is already there
  2. the foreground, animation, percentage are which is pure transparent and one can see the view under it
mrackwitz commented 10 years ago

If you only need to support iOS 8, then this will be a lot easier to implement. You could use a UIVisualEffectView with a UIBlurEffect and set its maskView to be any of the progress view or activity indicator view components provided by the library. But currently there are some traps around with the combination of UIVisualEffectView and maskView. You could duplicate rdar://18466755.

yasirmturk commented 10 years ago

iOS 8 is not a considerable market share right now ..we should support till iOS 6 ..but atleast can we have solution till iOS 7 and up

mrackwitz commented 10 years ago

Is your table scrollable? If the table cell could move or its background may change or you want to have animatable progress view components as cut out, things get tricky, perhaps not impossible but definitively more complex with each of the conditions you answer with YES.

If you want to have animations on the cut out, you need to come up with some serious tricks anyway, because UIKit (including UIVisualEffectView) doesn't support dynamic masks, as it clones the given view hierarchy and doesn't observe changes. Therefore you could consider trying to set the layer.mask property of a view (e.g. UIImageView) in foreground whose layer contains the rendered contents of the background of the cell. This has the advantage that you don't need to invert the mask, which is not possible in CoreAnimation in a generic way without going over rendered pixels. But there is the challenge that you need to update the contents when the background of the cell changes.

From my experience, I would say: don't try it at all or apply some dirty cheats somehow, so that it works only for your special case under certain conditions you can safely assume in the context of your App. If this is not possible, go back to the sketch and try to design something different.

But if you come up with an elegant solution for it, please let me know. :wink: