This is my @IBInspectable:
code:
@IBDesignable
class PBOView: UIView {
@IBInspectable var borderRightColor: UIColor? {
didSet {
let borderRightView = UIView(frame: CGRectMake(frame.size.width - 10, 0, 10, frame.size.height))
borderRightView.backgroundColor = borderRightColor
addSubview(borderRightView)
}
}
}
This is the result in Storyboard:
the width of UIView are 150
and in iPhone Simulator:
the width of UIView are 150
, but should be 80
since it is iPhone. This is why the rectangles are not visible inside my custom views
When I set clearColor
to the background of my views, the result is following:
Why there are a wrong bounds' and frames' width for that UIViews? Actually they are a width from Storyboard instead of a real widths at runtime.