2012-09-28 7 views
1

그림과 같이 둥근 사각형을 어떻게 만들 수 있습니까? 또한 두 번째 질문은 여러 줄을 얻는 방법, 붉은 사각형으로 표시된 것처럼 여러 줄로 서식을 지정하는 방법입니다. 사전에 감사드립니다!.둥근 사각형 상자 드로우 -iOS

CGRect viewRect=CGRectMake(30,30,320,55); 
UIView *myView=[[UIView alloc]initWithFrame:viewRect]; 
myView.backGroundColor=[UIColor whiteColor]; 
[self.view addSubview:myView] 

UILabel *label=[[UILabel alloc]initwithFrame:CGRectMake(30,32,25,12)]; 
label.font=[UIFont fontWithName:"System" size:12]; 
label.textColor=[UIColor blackColor]; 
[self.view addSubview:label] 

enter image description here

답변

1

당신은 아마 UITableView로 구현됩니다 제공된 예. 주소 셀의 왼쪽에는 textLabel ("주소")이고 오른쪽에는 detailTextLabel 스타일이있는 UITableViewCellStyleValue2 스타일이 있습니다.

다음은 세포를 포맷하는 방법은 다음과 같습니다

static NSString *CellIdentifier = @"MyCell"; 
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 
if (cell == nil) { 
    cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue2 reuseIdentifier:CellIdentifier]; 
} 
cell.textLabel.text = @"address"; 
cell.detailTextLabel.text = @"7200—7232 W Orem Dr\nHouston Texas 77085\nUnited States"; 
cell.detailTextLabel.numberOfLines = 3; 
cell.detailTextLabel.lineBreakMode = UILineBreakModeWordWrap; 

당신은 또한 기본보다 키가 될 것이기 때문에, 그에 따라 셀의 높이를 조정해야합니다.

출처 :Multi-line UITableViewCell using UILabel (a similar Stack Overflow question를 통해)

관련 문제