如何在iphone中为多屏幕层创建IBE

问题描述:

alt text如何在iphone中为多屏幕层创建IBE

我了解改变角落并禁用导航栏。但我需要通过xib构建。
现在你会明白我的问题。

我该如何构建我的uview,如示例1

您需要#import <QuartzCore/QuartzCore.h>,然后改变这样view.layer.cornerRadius = 4;

所需的UIView半径值举例来说,如果你有一个UIViewController,并要添加两种观点像上面这样做在的的loadView方法你viewcontroller:

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]; 

这将创建两个视图之一“内部”的其他两个圆角。

如果你想使视图 - 控制的初步意见圆角出现这样做:

-(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; 
} 

而此行补充:

window.backgroundColor = [UIColor blackColor]; 

到您的应用程序didFinishLaunchingWithOptions方法

+1

初始化你的视图,就像那个UIView * testView = [[UIView alloc] initWithFrame:CGRectMake(10,10,50,50)];然后testView.layer.cornerRadius = 4; – thomdask 2010-11-21 15:42:14

+0

谢谢。更改为[self.view addSubview:testView2]; 它工作正常。但我需要通过我的XIB构建,并需要将我的iPhone屏幕更改为最终角落。我们给出的解决方案是只创建单独的两个矩形屏幕。iPhone没有改变屏幕作为直角。 – SOF 2010-11-21 17:10:46

+0

您必须在IB中为您的视图设置插座。如果还不清楚,请阅读一些教程如何设计一个简单的视图应用程序。当你将视图设置为你的视图时,你的头文件中可以使用的可视对象为view1,view2,然后在源代码.m文件中,可以将其设置为view1.layer.cornerRadius = 8.0和view.layer.maskToBountds = YES。 – karim 2010-11-21 17:59:51

在顶部使用按钮视图可能是最简单的方法。

+0

没有按钮在IB图书馆中查看 – SOF 2010-11-21 15:41:20

+0

是的,它应该叫Round Rect Button。 – WaiLam 2010-11-22 15:07:02

棒一UIImageView在每个角落都有正确的角落图像。虽然...

+0

最后我得到了使用UIImage视图。这对我来说是很好的解决方案。非常感谢。 – SOF 2010-11-22 11:38:41