I want to configure a 5-star UIView, I also want it to appear in the storyboard. So I decided to use @IBDesignable and @ IBInspectable.The following is my code.
import UIKit @IBDesignable class RatingView: UIView { override init(frame: CGRect) { super.init(frame: frame) setUpView() } required init(coder aDecoder: NSCoder) { super.init(coder: aDecoder) setUpView() } func setUpView() { let imageView = UIImageView(frame:CGRectMake(0, 0, 50,50)) imageView.image = UIImage(named: "star") addSubview(imageView) } }
And then in my storyboard, I pulled a UIView into my canvas and set the Custom class for my custom view as RatingView. The compiler starts compiling the storyboard file, and I'm just waiting for the custom view to be displayed in canvas. Here is a screenshot. 
The status is "updated", but the view has not been rendered. The view simply remains white, I want to see the image that I add to the parent view. When I use UILabel instead of UIImageView, the label is renderd on the canvas, but not UIImageView, how can I display my beautiful star image on my canvas. (Images.xcassets has a star.png file)

use UILabel instead of UIImageView
func setUpView() { let label = UILabel(frame: CGRectMake(0, 0, 50, 50)) label.text = "text" addSubview(label) }
Result: 
source share