0

比。。。短

CGRect rect = self.webView.frame;
rect.origin = CGPointMake(0, 120);
self.webView.frame = rect;

或者这是最短的方法(或有效的)

4

2 回答 2

3

您可以使用 CGRectMake。四个参数.. x, y, width, height, all floats。像这样:self.webView.frame = CGRectMake(0, 0, 320, 480);

于 2011-01-19T02:37:50.740 回答
1

有几种方法可以定位视图。正如 donkim 建议的那样,您可以使用 CGRectMake。其他选项包括设置变换或设置中心,如果这些更容易处理的话。通常, CGRectMake 是要走的路,但我想把这些方法放在这里,以防它们在你的情况下更有用:

//Sets the webView's center, automatically adjusting the frame
self.webView.center = CGPointMake(x,y);

或者

//Moves where the webview shows up away from its current location, but does not technically adjust its location.
self.webView.transform = CGAffineTransformMakeTranslation(0,120);
于 2011-01-19T04:02:09.973 回答