سؤال

how can i add an X looking red stroke to a UIImageView.

i would like to add 2 diagonal red lines to a UIImageView, is there a way to do it programmatically using layers or masks? (not in drawRect)

هل كانت مفيدة؟

المحلول

Use a CAShapeLayer with your X shape as its path. Depending on how you've drawn the path, you may want to set a nil fill colour (since a path just made of two crossed lines should not be filled).

Add the shape layer as a sublayer of your image view.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top