I have a UICollectionViewCell subclass that contains a UIImageView. When a given cell is selected, I'd like to add a fixed-width border around the image (ie extending from the image view, not within it). Can anyone recommend a good approach?
Incidentally, I'm using storyboards.
What I ended up doing was enlarging the UIImageView (adding the width of the margins), then redrawing the UIImage twice (once with a black border, once with a colored border). I then toggled between imageView.image and imageView.highlightedImage when the cell is selected. Ie imageView.highlighted = cell.selected
It requires more processing up-front, since each original UIImage is drawn out twice, but if the resulting images are cached (and the originals small) then it's not a big deal.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.