【问题标题】:how to change only left radius of UIbutton in swift [duplicate]如何在swift中仅更改UIbutton的左半径[重复]
【发布时间】:2016-03-17 00:49:34
【问题描述】:

问题: 如何只改变ui按钮的左侧半径??

问题: 我认为我有一个 3 uibutton。 我只想改变uibutton的左侧radius 这是我的代码

 btnsetting.layer.cornerRadius = 5
btnsaved.layer.cornerRadius = 5
btnall.layer.cornerRadius = 5

但它给两边的半径..

我想做什么:

【问题讨论】:

  • 为什么不使用分段控件?否则你应该为你的按钮使用背景图片。你不能给单边圆角半径
  • 它对我有用,谢谢@Anbu.Karthik

标签: ios iphone swift uibutton ios9


【解决方案1】:

你必须:

  • 创建CAShapeLayer
  • 将其路径设置为基于 view.bounds 但只有两个圆角的 CGPathRef(可能使用+[UIBezierPath bezierPathWithRoundedRect:byRoundingCorners:cornerRadii:])
  • 将您的view.layer.mask 设置为CAShapeLayer

信用:https://stackoverflow.com/a/10167334/2303865

【讨论】:

猜你喜欢
  • 1970-01-01
  • 2015-01-06
  • 1970-01-01
  • 1970-01-01
  • 2017-10-05
  • 1970-01-01
  • 1970-01-01
  • 2016-09-07
  • 2014-07-07
相关资源
最近更新 更多