0

I've implemented a custom UIView and have assigned this CustomUIView to the File's Owner, I outlet-ed a UIImageView in the CustomUIView as below

@IBOutlet weak var messageCardView: UIImageView!

And I've implemented init function:

required init?(coder aDecoder: NSCoder) {
    super.init(coder: aDecoder)

    messageCardView.image = UIImage(named: "img_1")
    messageCardView.alpha = 0.5
}

I'd like the alpha attribute and image showing in my xib static file, is there any way to do that? Great thanks!

KAs
  • 1,818
  • 4
  • 19
  • 37

1 Answers1

0

Just add @IBDesignable before your class declaration, like this:

@IBDesignable
public class CustomUIView : UIView {
    ...

It may not work until you save / reload your XIB, though.

More info: http://nshipster.com/ibinspectable-ibdesignable/#ibdesignable

Jorge Martín
  • 268
  • 3
  • 13
  • Great help! Could you go a little bit further regarding how to save/reload my XIB? Thanks man! – KAs Aug 22 '16 at 10:07