0

希望有人可以帮助我.... 我创建了一个 UISegmented 控件并开始将其更改为我的应用程序设计 - 请参见下面的屏幕截图。

如果你们能看到分段选项的背景,你们就会看到我的问题。我设法使用以下功能更改颜色、文本和其他一些小东西:

到目前为止我所拥有的

extension UISegmentedControl {

func defaultConfiguration(font: UIFont = UIFont(name: "Montserrat-Regular", size: 13)!, textColor: UIColor = UIColor.white, backgroundColor: UIColor = UIColor.clear) {
    let defaultAttributes: [NSAttributedString.Key : Any] = [
        NSAttributedString.Key(rawValue: NSAttributedString.Key.font.rawValue): font,
        NSAttributedString.Key(rawValue: NSAttributedString.Key.foregroundColor.rawValue): textColor,
        NSAttributedString.Key(rawValue: NSAttributedString.Key.backgroundColor.rawValue): backgroundColor
    ]
    setTitleTextAttributes(defaultAttributes, for: .normal)
}

func selectedConfiguration(font: UIFont = UIFont(name: "Montserrat-Regular", size: 13)!, textColor: UIColor = UIColor.rgb(red: 52, green: 0, blue: 177), backgroundColor: UIColor = UIColor.white) {
    let selectedAttributes: [NSAttributedString.Key : Any] = [
        NSAttributedString.Key(rawValue: NSAttributedString.Key.font.rawValue): font,
        NSAttributedString.Key(rawValue: NSAttributedString.Key.foregroundColor.rawValue): textColor,
        NSAttributedString.Key(rawValue: NSAttributedString.Key.backgroundColor.rawValue): backgroundColor
    ]
    setTitleTextAttributes(selectedAttributes, for: .selected)
    }
}

我希望背景更大更圆......我缺少什么想法吗?当用户点击时,它应该看到以下内容

我需要的:

4

0 回答 0