fixed the error in previouse version that label attribute preferredMaxLayoutWidth should be depending on the width its superview, not of self.view. Updated example with multi line label in custom view.