DTGradientButton 라이브러리를 사용해 보았습니다.
7117 단어 Xcode버튼DTGradientButton
환경
・Mac Book Pro(macOS:BigSur)
・Xcode(ver:12.5)
구현 예
코드 예
ViewController.swiftclass ViewController: UIViewController {
@IBOutlet weak var gradientButton1: UIButton!
@IBOutlet weak var gradientButton2: UIButton!
@IBOutlet weak var gradientButton3: UIButton!
@IBOutlet weak var gradientButton4: UIButton!
override func viewDidLoad() {
super.viewDidLoad()
let colors1 = [UIColor(named:"Color1")!, UIColor(named: "Color2")!]
let colors2 = [UIColor(named:"Color3")!, UIColor(named: "Color4")!]
let colors3 = [UIColor(named:"Color5")!, UIColor(named: "Color6")!]
let colors4 = [UIColor(named:"Color7")!, UIColor(named: "Color8")!]
gradientButton1.setGradientBackgroundColors(colors1, direction: .toTop, for: .normal)
gradientButton1.layer.cornerRadius = 10.0
gradientButton1.layer.masksToBounds = true
gradientButton2.setGradientBackgroundColors(colors2, direction: .toBottom, for: .normal)
gradientButton2.layer.cornerRadius = 10.0
gradientButton2.layer.masksToBounds = true
gradientButton3.setGradientBackgroundColors(colors3, direction: .toBottomLeft, for: .normal)
gradientButton3.layer.cornerRadius = 10.0
gradientButton3.layer.masksToBounds = true
gradientButton4.setGradientBackgroundColors(colors4, direction: .toBottomRight, for: .normal)
gradientButton4.layer.cornerRadius = 10.0
gradientButton4.layer.masksToBounds = true
}
}
Reference
이 문제에 관하여(DTGradientButton 라이브러리를 사용해 보았습니다.), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다
https://qiita.com/swiftEnginnerY/items/9206ab09eaeb6fd41653
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)
코드 예
ViewController.swiftclass ViewController: UIViewController {
@IBOutlet weak var gradientButton1: UIButton!
@IBOutlet weak var gradientButton2: UIButton!
@IBOutlet weak var gradientButton3: UIButton!
@IBOutlet weak var gradientButton4: UIButton!
override func viewDidLoad() {
super.viewDidLoad()
let colors1 = [UIColor(named:"Color1")!, UIColor(named: "Color2")!]
let colors2 = [UIColor(named:"Color3")!, UIColor(named: "Color4")!]
let colors3 = [UIColor(named:"Color5")!, UIColor(named: "Color6")!]
let colors4 = [UIColor(named:"Color7")!, UIColor(named: "Color8")!]
gradientButton1.setGradientBackgroundColors(colors1, direction: .toTop, for: .normal)
gradientButton1.layer.cornerRadius = 10.0
gradientButton1.layer.masksToBounds = true
gradientButton2.setGradientBackgroundColors(colors2, direction: .toBottom, for: .normal)
gradientButton2.layer.cornerRadius = 10.0
gradientButton2.layer.masksToBounds = true
gradientButton3.setGradientBackgroundColors(colors3, direction: .toBottomLeft, for: .normal)
gradientButton3.layer.cornerRadius = 10.0
gradientButton3.layer.masksToBounds = true
gradientButton4.setGradientBackgroundColors(colors4, direction: .toBottomRight, for: .normal)
gradientButton4.layer.cornerRadius = 10.0
gradientButton4.layer.masksToBounds = true
}
}
Reference
이 문제에 관하여(DTGradientButton 라이브러리를 사용해 보았습니다.), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다
https://qiita.com/swiftEnginnerY/items/9206ab09eaeb6fd41653
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)
class ViewController: UIViewController {
@IBOutlet weak var gradientButton1: UIButton!
@IBOutlet weak var gradientButton2: UIButton!
@IBOutlet weak var gradientButton3: UIButton!
@IBOutlet weak var gradientButton4: UIButton!
override func viewDidLoad() {
super.viewDidLoad()
let colors1 = [UIColor(named:"Color1")!, UIColor(named: "Color2")!]
let colors2 = [UIColor(named:"Color3")!, UIColor(named: "Color4")!]
let colors3 = [UIColor(named:"Color5")!, UIColor(named: "Color6")!]
let colors4 = [UIColor(named:"Color7")!, UIColor(named: "Color8")!]
gradientButton1.setGradientBackgroundColors(colors1, direction: .toTop, for: .normal)
gradientButton1.layer.cornerRadius = 10.0
gradientButton1.layer.masksToBounds = true
gradientButton2.setGradientBackgroundColors(colors2, direction: .toBottom, for: .normal)
gradientButton2.layer.cornerRadius = 10.0
gradientButton2.layer.masksToBounds = true
gradientButton3.setGradientBackgroundColors(colors3, direction: .toBottomLeft, for: .normal)
gradientButton3.layer.cornerRadius = 10.0
gradientButton3.layer.masksToBounds = true
gradientButton4.setGradientBackgroundColors(colors4, direction: .toBottomRight, for: .normal)
gradientButton4.layer.cornerRadius = 10.0
gradientButton4.layer.masksToBounds = true
}
}
Reference
이 문제에 관하여(DTGradientButton 라이브러리를 사용해 보았습니다.), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/swiftEnginnerY/items/9206ab09eaeb6fd41653텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)