Question

I've tried to modify a few traits of an existing UIView such as its frame and its backgroundColor, and nothing happens any time I do it. I've looked at some of the answers on here, but none of them have worked for me. I've been able to modify a UIView and then place it as a subview before, but never one that was in the xib or storyboard from the start (xib because I've been working an old project at my work). To be clear the views I've been trying to modify are not self.view, always subviews that were created before hand.

example code:

@property (strong, nonatomic) IBOutlet UIView *toEdit;

[_toEdit setFrame:CGRectMake(self.view.frame.origin.x, self.view.frame.origin.y, 200, 200)];
Was it helpful?

Solution

As explained here, have you tried connecting the elements in the xib to the code throughout Outlets? Ctrl+click on the ui element in the Interface Builder element and release on the relative property of the relative header.

In case you use an Autolayout, the Frame system changes totally and you will not be able anymore (lets say) to edit position directly if not using Constraints.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top