メッセージは左揃えにする必要がありますが、UIAlertView のタイトルのみを中央揃えにしたいと思います。
現在、私はやっています
((UILabel*)[[alert subviews] objectAtIndex:1]).textAlignment = NSTextAlignmentCenter;
しかし、メッセージも中央に配置されます。
メッセージは左揃えにする必要がありますが、UIAlertView のタイトルのみを中央揃えにしたいと思います。
現在、私はやっています
((UILabel*)[[alert subviews] objectAtIndex:1]).textAlignment = NSTextAlignmentCenter;
しかし、メッセージも中央に配置されます。
UIAlertView のデフォルトのラベルを変更しようとはしません。代わりに、新しい UILabel を作成してサブビューとして追加する必要があります。
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Centered Title" message:@"\n\n\n" delegate:self cancelButtonTitle:@"Close" otherButtonTitles:nil];
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(12.0, 24.0, 250.0, 80.0)];
label.numberOfLines = 0;
label.textAlignment = NSTextAlignmentLeft;
label.backgroundColor = [UIColor clearColor];
label.textColor = [UIColor whiteColor];
label.text = @"Here is an example of a left aligned label in a UIAlertView!";
[alert addSubview:label];
[alert show];