is there an easier way to set a view's origin and size on iphone
Shorter than
CGRect rect = self.webView.frame;
rect.origin = CGPointMake(0, 120);
self.webView.frame = rect;
开发者_JAVA百科
Or is this the shortest way (or efficient)
You can use CGRectMake. Four parameters.. x, y, width, height, all floats. Like this: self.webView.frame = CGRectMake(0, 0, 320, 480);
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);
精彩评论