たとえば、iPad の画面全体を覆う 100 x 100 ピクセルの円をメイン ビューに描画する場合は、initWithFrame
次の 2 つの手順を使用する代わりに、次のようにしますviewDidLoad
。
UINodeView *nodeView = [[UINodeView alloc] initWithFrame:
CGRectMake(x, y, NSNodeWidth, NSNodeHeight)];
nodeView.center = CGPointMake(x, y);
x
とは、 の代わりに円を水平方向に中央揃えにするため、y
より洗練されているためです。最初にフレームで、次に中心をリセットするのが良い方法ですか、それともより良い方法がありますか?self.view.bounds.size.width / 2
self.view.bounds.size.width / 2 - NSNodeWidth / 2
init
initWithCenterAndSize