29
27

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

SDK7.1 + iOS7.1でUILabelのcornerRadiusの挙動が変わった

Last updated at Posted at 2014-03-13

UILabelの角を丸くするためにcornerRadiusを設定していたのですが、SDK7.1を使ってコンパイルしてiOS7.1の環境で動作させると挙動が変わるようです。

サンプルコード
	UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(15, 45, 130, 30)];
    label.backgroundColor = [UIColor colorWithWhite:0 alpha:0.8];
    label.textColor = [UIColor whiteColor];
    label.textAlignment = NSTextAlignmentCenter;
    label.text = @"Takabo Soft";
    label.layer.cornerRadius = 15; // ←角丸
    [self.view addSubview:label];

各OSでの実行結果:
label.png

回避方法:
クリップしてやれば良さそうです。

サンプルコード
	UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(15, 45, 130, 30)];
    label.backgroundColor = [UIColor colorWithWhite:0 alpha:0.8];
    label.textColor = [UIColor whiteColor];
    label.textAlignment = NSTextAlignmentCenter;
    label.text = @"Takabo Soft";
    label.layer.cornerRadius = 15;
    label.clipsToBounds = YES;	// ←これ
    [self.view addSubview:label];

参考:http://stackoverflow.com/questions/22348353/corner-radius-property-of-uilabel-is-not-working-in-ios-7-1

ちなみに過去のアプリ(SDK7.0でコンパイルしたアプリ)はiOS7.1で実行しても角丸になっていました。

29
27
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
29
27

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?