Reputation: 4116
I'm hoping to preview the tint color of my images in the Interface Builder (for designers' sakes) but have had no luck. I tried setting the image asset rendering mode to Template & then selecting a tint in Interface Builder, with no luck. Is there any way to do this? If code is required, please provide an answer with Swift. Thanks!
Upvotes: 1
Views: 776
Reputation: 4116
Despite no help from downvoters, I found a partial answer. I subclassed my image view like this -
@IBDesignable
class TintPreviewableImage: UIImageView {
override func prepareForInterfaceBuilder() {
self.image = self.image?.withRenderingMode(.alwaysTemplate)
}
}
Then I added the TintPreviewableImage
class to the UIImageView in the identity inspector. Now I see a live preview after selecting a tint color in the Interface Builder. The only problem is the icon is blurry if the image view is bigger than the native size - I'm still trying to get Xcode to redraw the PDF vector image.
Upvotes: 5