如何在iphone中为多个屏幕层构建IB

SOF*_*SOF 1 iphone cocoa-touch interface-builder

替代文字

我明白改变角落并禁用导航栏.但我需要在xib中构建.
现在你将清楚地了解我的问题.

我怎样才能像样本一样构建我的uiview.

tho*_*ask 6

您需要#import <QuartzCore/QuartzCore.h>然后更改所需的UIView上的半径值view.layer.cornerRadius = 4;

例如,如果您有一个UIViewController并且想要添加上面的两个视图,那么您可以在viewcontroller的loadView方法中执行此操作:

UIView *testView1 = [[UIView alloc] initWithFrame:CGRectMake(10,10,200,200)];
UIView *testView2 = [[UIView alloc] initWithFrame:CGRectMake(20,20,150,150)];
[testView1 setBackgroundColor:[UIColor greenColor]];
[testView2 setBackgroundColor:[UIColor blackColor]];
testView1.layer.cornerRadius = 4;
testView2.layer.cornerRadius = 4;
[self.view addSubview testView1];
[self.view addSubview testView2];
[testView1 release];
[testView2 release];
Run Code Online (Sandbox Code Playgroud)

这将创建两个视图,一个"内部",另一个都带有圆角.

如果你想让viewcontroller的初始视图显示圆角,请执行以下操作:

-(void)loadView {
 UIView *view = [[UIView alloc] init];
 [view setBackgroundColor:[UIColor redColor]];
 view.layer.cornerRadius = 15;
 self.view =view;
 [view release];
}

-(void)viewDidLoad {
 self.navigationController.navigationBarHidden = YES;
}
Run Code Online (Sandbox Code Playgroud)

并添加此行:

window.backgroundColor = [UIColor blackColor];
Run Code Online (Sandbox Code Playgroud)

给你的应用程序didFinishLaunchingWithOptions方法