27 lines
754 B
Swift
27 lines
754 B
Swift
|
//
|
||
|
// Button.swift
|
||
|
// Befund
|
||
|
//
|
||
|
// Created by Irakli Abetschkhrischwili on 02.06.22.
|
||
|
// Copyright © 2022 MVZ Dr. Stein und Kollegen. All rights reserved.
|
||
|
|
||
|
|
||
|
import Foundation
|
||
|
import UIKit
|
||
|
|
||
|
extension UIButton
|
||
|
{
|
||
|
/**
|
||
|
* Sets the background color for UIButton for a state
|
||
|
*/
|
||
|
func setBackgroundColor(color: UIColor, forState: UIControl.State)
|
||
|
{
|
||
|
UIGraphicsBeginImageContext(CGSize(width: 1, height: 1))
|
||
|
UIGraphicsGetCurrentContext()!.setFillColor(color.cgColor)
|
||
|
UIGraphicsGetCurrentContext()!.fill(CGRect(x: 0, y: 0, width: 1, height: 1))
|
||
|
let colorImage = UIGraphicsGetImageFromCurrentImageContext()
|
||
|
UIGraphicsEndImageContext()
|
||
|
self.setBackgroundImage(colorImage, for: forState)
|
||
|
}
|
||
|
}
|