gpt4 book ai didi

ios - 快捷按钮概述

转载 作者:行者123 更新时间:2023-12-01 19:54:23 26 4
gpt4 key购买 nike

我是快速编程的新手,我正在尝试制作钢琴应用。有谁知道在Swift中为按钮添加边框吗?
我在互联网上进行搜索,但所有教程均针对较早版本的Swift,并且不再起作用。

最佳答案

UIButton继承自UIControl,UIControl继承自
UIView。
UIView包含用于渲染的CALayer(核心动画层)。
https://developer.apple.com/reference/quartzcore/calayer

import UIKit
import PlaygroundSupport

let button = UIButton(type: .custom)
button.frame = CGRect(x: 0, y: 0, width: 100, height: 100)
button.backgroundColor = .red
button.layer.borderWidth = 2.0
button.layer.borderColor = UIColor.green.cgColor

PlaygroundPage.current.liveView = button

关于ios - 快捷按钮概述,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43561859/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com