Help us understand the problem. What is going on with this article?

UIView(写真やラベルやView)の角を丸める方法

More than 3 years have passed since last update.

今回行うこと

  1. ラベルを貼る
  2. 角を丸めるコードを書く
  3. 実行結果の確認

  1. ラベルを貼る
    StoryBoardにUILabelを貼る

    ViewControllerにUILabelに関連付けする
    スクリーンショット 2015-10-31 18.23.18.png

  2. 角を丸めるコードを書く


ViewController.swift
//
//  ViewController.swift
//  TestProject
//
//  Created by 坂本 大介 on 10/31/15.
//  Copyright © 2015 Daisuke Sakamoto. All rights reserved.
//

import UIKit

class ViewController: UIViewController {

    @IBOutlet weak var testLabel: UILabel!

    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.

        //丸める半径の指定
        testLabel.layer.cornerRadius = 20;

        //丸める許可
        testLabel.clipsToBounds = true;

    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
}

3. 実行結果の確認

スクリーンショット 2015-10-31 18.28.15.png

まとめ

簡単に丸めることができましたね
この丸め方はLayerクラスをもつUIImageView,UIViewなどいろいろなところで活用できます!

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした