I am trying to add a UILB at the top of my ideas which can be multiple lines. I have done so much research but I am not able to do this work because it will show only one line and I want to be as big as it should be. I am doing this with automatic layout and the current code I have is:
UILabel * label = [[UILabel alloc] init]; Label.translatesAutoresizingMaskIntoConstraints = No; Label.text = @ "jklljk sdkhfdjkdsfjhkfk fhs fdh fk dksdks dfss s dfs dfs fsdkdfks dfks dfks df k dfh"; Label.numberOfLines = 0; NSDictionary * view = @ {@ "label": label}; [Self.view addSubview: label]; [Self.view addConstraints: [NSLayoutConstraint constraintsWithVisualFormat: @ "H: | [label] |" Options: 0 metric: zero views: view]]; [Self.view addConstraints: [NSLayoutConstraint constraintsWithVisualFormat: @ "V: | [label (& gt; = 20)]" Options: 0 metric: zero views: consideration]];
You have to set a frame on the label to set the initial position in the view.
From the Programming Guide:
When adding a subview to its original, the current frame rectangle of the subview shows its initial position within the parent's viewing.
/ blockquote>
Comments
Post a Comment