2010-11-21 2 views

답변

6

당신은 #import <QuartzCore/QuartzCore.h> 필요 예를 들어 당신이 UIViewController에있는 경우,이 view.layer.cornerRadius = 4;

같은 원하는 UIView의에 반경 값을 변경하고의에는 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]; 

두 개의 뷰가 하나의 "안쪽에"있고 둘 다 둥근 모서리가 생성됩니다. 방법

+1

UIView * testView = [[UIView alloc] initWithFrame : CGRectMake (10,10,50,50)];와 같이보기 초기화하기; 그런 다음 testView.layer.cornerRadius = 4; – thomdask

+0

감사합니다. [self.view addSubview : testView2]로 변경하십시오. 잘 작동합니다. 하지만 내 XIB를 통해 빌드하고 rect 코너로 내 아이폰 화면을 변경해야합니다. 우리가 솔루션을 준 것은 단지 두 개의 rect rect corner screen을 생성하는 것입니다. rect corner와 같은 iphone의 변경 화면은 없습니다. – SOF

+0

IB에서보기를 위해 콘센트를 설정해야합니다. 아직 명확하지 않은 경우 간단한보기 응용 프로그램을 디자인하는 방법을 몇 가지 자습서로 읽어보십시오. 콘센트를 뷰에 설정하면 헤더 파일의 유동성은 view1, view2이고 소스 코드 .m 파일에서는 view1.layer.cornerRadius = 8.0 및 view.layer.maskToBountds = YES로 설정할 수 있습니다. – karim

2

상단의 버튼보기를 사용하면 간단한 방법 일 수 있습니다.

+0

IB 라이브러리에서보기 – SOF

+0

예, 둥근 사각형 버튼이라고합니다. – WaiLam

2

스틱 응용 프로그램 didFinishLaunchingWithOptions에

window.backgroundColor = [UIColor blackColor]; 

: 당신의 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; 
} 

을 그리고이 줄을 추가 올바른 코너 이미지가있는 각 구석의 UIImageView. 그래도 탐색 모음에는 효과가 없을 것입니다 ...

+0

마지막으로 UIImage 뷰를 사용하고 있습니다. 이것은 나를위한 좋은 해결책이다. 고마워. – SOF

관련 문제