보기의 맨 위에 레이블을 배치하여 중앙에 배치하는 데 문제가 있습니다. 그러나 날짜를 사용함에 따라 문자열의 너비가 다양합니다. 나는 또한 3.5 인치 스크린에서 텍스트가 맞지 않는다는 것을 알았다. 라벨의 양쪽에 두 개의 이미지 버튼이 있습니다.Obj-C, 뷰의 레이블 가운데 맞추기/
그래서 여백이 필요합니다. 문제를 더욱 복잡하게
는보기가 아니라 풍경에 표시, 그래서 왼쪽은 내가 할 필요가
ViewController *nextController = [[ViewController alloc]
initWithNibName:@"View" bundle:nil];
CGAffineTransform newTransform = CGAffineTransformMake(0.0,1.0,-1.0,0.0,0.0,0.0);
nextController.view.transform = newTransform;
nextController.hidesBottomBarWhenPushed = YES;
나는 모든 생각 했 등 최고입니다했다 ...
int margin = 50;
lblTitle.frame = CGRectMake(margin, 2, th - (margin * 2), 22);
하지만 그건 작동하지 않습니다. 왼쪽에 상태 표시 줄의 높이를 추가하는 것과 거의 같지만 상태 표시 줄은 표시됩니다. 나는 수많은 시도를했는데, 내가 뭘 잘못하고 있는지 확신 할 수 없었다.
lblTitle = [[UILabel alloc] initWithFrame:CGRectZero];
lblTitle.text = [NSString stringWithFormat:@"%@ - from %@ to %@",
strChartType, displayStartDate, displayEndDate];
int th = self.view.frame.size.height;
//int th = self.view.bounds.size.height;
lblTitle.frame = CGRectMake(0, 2, th, 22); // x, y, w, h
//[lblTitle setAutoresizingMask:UIViewAutoresizingFlexibleLeftMargin |
UIViewAutoresizingFlexibleRightMargin];
//lblTitle.center = CGPointMake(self.view.bounds.size.width/2, 10);
[lblTitle setTextAlignment:UITextAlignmentCenter];
lblTitle.font = [UIFont boldSystemFontOfSize:14];
lblTitle.adjustsFontSizeToFitWidth = FALSE;
lblTitle.backgroundColor = [UIColor yellowColor];
[self.view addSubview:lblTitle];
'CGRectGetMidX()'와'CGRectGetMidY()'는 도움이되어야합니다. –
평가 대상은 무엇이며, 무엇이 좋을 것이라고 생각합니까? – Joel