Reputation: 2742
Shorter than
CGRect rect = self.webView.frame;
rect.origin = CGPointMake(0, 120);
self.webView.frame = rect;
Or is this the shortest way (or efficient)
Upvotes: 0
Views: 1670
Reputation: 39690
There are several ways to position a view. As donkim suggested, you could use CGRectMake. Other options include setting the transform, or setting the center, if those are easier to deal with. Usually, CGRectMake is the way to go, but I'd like to put these methods here just in case they are more useful in your case:
//Sets the webView's center, automatically adjusting the frame
self.webView.center = CGPointMake(x,y);
or
//Moves where the webview shows up away from its current location, but does not technically adjust its location.
self.webView.transform = CGAffineTransformMakeTranslation(0,120);
Upvotes: 1
Reputation: 13137
You can use CGRectMake. Four parameters.. x, y, width, height, all floats. Like this: self.webView.frame = CGRectMake(0, 0, 320, 480);
Upvotes: 3