Interface Builder Clipping Designable Views

I really need a hand here. I created a subclass of @IBDesignable UILabel that works fine in the XCode Interface Builder. However, even if I set 'clipsToBounds' to false, Interface Builder will still clamp it, and changing @IBInspectable properties will work.

If I run the application on a simulator or device, UILabel does not crop and gives me the desired results (while still applying the values ​​that the Builder interface has).

BEFORE CHANGE (visible areas visible) Before the change

AFTER CHANGE IN THE INTERFACE-BUILDER (eyeliners are out of sight) After the change (builder)

AFTER CHANGE IN SIMULATOR (Subsections are expected) After the change (simulator)

Any help would be greatly appreciated. The code for the custom class is below.

@IBDesignable class UIFeaturedLabel: UILabel { @IBInspectable var borderWidth: Float = 4 @IBInspectable var borderOffsetX: Float = 15 @IBInspectable var borderOffsetY: Float = 5 @IBInspectable var borderColor: UIColor = UIColor.whiteColor() private var headerView:UIView! private var footerView:UIView! override init() { super.init() createViews() } required init(coder aDecoder: NSCoder) { super.init(coder: aDecoder) createViews() } override init(frame: CGRect) { super.init(frame: frame) createViews() } func createViews() { clipsToBounds = false layer.masksToBounds = false headerView = UIView() footerView = UIView() headerView.backgroundColor = UIColor.whiteColor() footerView.backgroundColor = UIColor.whiteColor() addSubview(headerView) addSubview(footerView) } override func layoutSubviews() { super.layoutSubviews() let left = CGFloat( -borderOffsetX ) let right = CGFloat( frame.width + CGFloat(borderOffsetX*2) ) let top = CGFloat( -borderOffsetY ) let bottom = CGFloat( frame.height - CGFloat(borderWidth/2) ) + CGFloat( borderOffsetY ) headerView.frame = CGRectMake(left, top, right, CGFloat(borderWidth)) footerView.frame = CGRectMake(left, bottom, right, CGFloat(borderWidth)) } } 
+5
source share
1 answer

Still happening with Xcode 7.3 iOS9.3, but fixed in Xcode version 8.0 beta (8S128d).

+2
source

Source: https://habr.com/ru/post/1207956/


All Articles