70 lines
1.9 KiB
Swift
70 lines
1.9 KiB
Swift
//
|
|
// AddButton.swift
|
|
// Befund
|
|
//
|
|
// Created by Irakli Abetschkhrischwili on 19.05.22.
|
|
// Copyright © 2022 MVZ Dr. Stein und Kollegen. All rights reserved.
|
|
|
|
import Foundation
|
|
import UIKit
|
|
|
|
@IBDesignable class AddButton: UIButton
|
|
{
|
|
override init(frame: CGRect)
|
|
{
|
|
super.init(frame: frame)
|
|
initialize()
|
|
}
|
|
|
|
required init(coder aDecoder: NSCoder)
|
|
{
|
|
super.init(coder: aDecoder)!
|
|
}
|
|
|
|
override func layoutSubviews()
|
|
{
|
|
super.layoutSubviews()
|
|
initialize()
|
|
}
|
|
|
|
func initialize()
|
|
{
|
|
let screenBound = UIScreen.main.bounds;
|
|
|
|
var width = CGFloat((screenBound.width * 30) / 180.0)
|
|
|
|
if(width > 60.0)
|
|
{
|
|
width = CGFloat(60.0)
|
|
}
|
|
|
|
frame.size.width = width
|
|
frame.size.height = width
|
|
|
|
layer.cornerRadius = width / 2
|
|
|
|
frame.origin.y = (screenBound.height - 60) - (frame.height / 2.0)
|
|
frame.origin.x = (screenBound.width / 2.0) - (frame.width / 2.0)
|
|
layer.cornerRadius = bounds.size.height / 2.0
|
|
clipsToBounds = true
|
|
let gradient = CAGradientLayer()
|
|
gradient.frame = bounds
|
|
gradient.colors = [UIColor.white.cgColor, UIColor(red: 226/255.0, green: 0.0, blue: 122.0/255.0, alpha: 1.0).cgColor]
|
|
gradient.startPoint = CGPoint(x: 1.0, y: 0.5)
|
|
gradient.endPoint = CGPoint(x: 1.0, y: 0.5)
|
|
let shape = CAShapeLayer()
|
|
shape.lineWidth = 5
|
|
shape.path = UIBezierPath(
|
|
arcCenter: CGPoint(x: bounds.height/2,
|
|
y: bounds.height/2),
|
|
radius: bounds.height/2,
|
|
startAngle: CGFloat(0),
|
|
endAngle:CGFloat(CGFloat.pi * 2),
|
|
clockwise: true).cgPath
|
|
shape.strokeColor = UIColor.black.cgColor
|
|
shape.fillColor = UIColor.clear.cgColor
|
|
gradient.mask = shape
|
|
layer.addSublayer(gradient)
|
|
}
|
|
}
|