如何在iphone中为多屏幕层创建IBE
答
您需要#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方法
答
棒一UIImageView在每个角落都有正确的角落图像。虽然...
+0
最后我得到了使用UIImage视图。这对我来说是很好的解决方案。非常感谢。 – SOF 2010-11-22 11:38:41
初始化你的视图,就像那个UIView * testView = [[UIView alloc] initWithFrame:CGRectMake(10,10,50,50)];然后testView.layer.cornerRadius = 4; – thomdask 2010-11-21 15:42:14
谢谢。更改为[self.view addSubview:testView2]; 它工作正常。但我需要通过我的XIB构建,并需要将我的iPhone屏幕更改为最终角落。我们给出的解决方案是只创建单独的两个矩形屏幕。iPhone没有改变屏幕作为直角。 – SOF 2010-11-21 17:10:46
您必须在IB中为您的视图设置插座。如果还不清楚,请阅读一些教程如何设计一个简单的视图应用程序。当你将视图设置为你的视图时,你的头文件中可以使用的可视对象为view1,view2,然后在源代码.m文件中,可以将其设置为view1.layer.cornerRadius = 8.0和view.layer.maskToBountds = YES。 – karim 2010-11-21 17:59:51