0
1

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 3 years have passed since last update.

iOS13以降のSegmentedControlで下線を端まで伸ばす

Posted at

はじめに

よくある上タブ実装でタップしているタブの下に下線をCALayerで引くというのをやったんですが、iOS13以降だと角が丸まってしまいました。

スクリーンショット 2021-02-19 15.18.38.png

その際にこちらを参考にして対応しました。

Sampleコード


/// iOS13以降だとSegmentedの角が自動で丸まってしまうので、Radiusを上書きしたclassを用意
class SquareSegmentedControl: UISegmentedControl {
    override func layoutSubviews() {
        super.layoutSubviews()
        layer.cornerRadius = 0
    }
}

スクリーンショット 2021-02-19 14.47.12.png

0
1
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
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?