如何更改 UISegmentedControl 的圆角半径? [英] How to change the corner radius of UISegmentedControl?

查看:38
本文介绍了如何更改 UISegmentedControl 的圆角半径?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

UISegmentedControl 的圆角半径可以改变吗?我尝试了以下方法来更改 UIView 的角半径.

Is it possible to change the corner radius of UISegmentedControl? I have tried the following approach which we use to change a UIView's corner radius.

self.segmentedControl.layer.cornerRadius = 15.0;
self.segmentedControl.layer.masksToBounds = YES;

这不起作用,因为你可以看到它只切断了 UISegmentedControl 的角落:

This did not work as you can see it only cuts off the UISegmentedControl's corner:

推荐答案

这应该有效:

self.segmentedControl.layer.cornerRadius = 15.0;
self.segmentedControl.layer.borderColor = [UIColor whiteColor].CGColor;
self.segmentedControl.layer.borderWidth = 1.0f;
self.segmentedControl.layer.masksToBounds = YES;

设置cornerRadius后需要指定边框.

You need to specify the border after setting cornerRadius.

这篇关于如何更改 UISegmentedControl 的圆角半径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆