Aqlier/ 8月 14, 2017/ iPhone

Xcode 開発(iosアプリ)で、円形ボタンを使用したいときの対処方法です。

Xcode 開発で対処可能な方法
1.ボタンの角丸の応用
2.丸いボタンの画像+透明色ボタンの組み合わせ

以下は、「1.ボタンの角丸の応用」の方法が容易で、対応方法をまとめました。

以下の画像は、 Xcode の標準で対応可能な方法です。


対応方法


ボタン1: Xcode の標準ボタン
ボタン2:角丸ボタン
ボタン3:楕円ボタン
ボタン4:円ボタン

これらの違いは、cornerRadiusの値の違いになります。

また、楕円と円の違いで、円はもとのボタンの設定が正方形でcornerRadiusの2倍の値を幅・高さにセットします。

ボタン1:bu1、ボタン2:bu2、ボタン3:bu3、ボタン4:bu4

@implementation ViewController
@synthesize bu1;
@synthesize bu2;
@synthesize bu3;
@synthesize bu4;

- (void)viewDidLoad {
    [super viewDidLoad];

    bu1.layer.cornerRadius = 0;
    bu2.layer.cornerRadius = 10;
    bu3.layer.cornerRadius = 30;
    bu4.layer.cornerRadius = 30;
    
}
0 0 投票
記事の評価

記事内容に関して、不明点・誤りがありましたらコメントをお願いします。

0 Comments
Inline Feedbacks
View all comments