+7 771 559 26 76
sguruapp@gmail.com
Меню
×
Мобильные
приложения
Курсы по
программированию
Цены
на услуги
Наши
контакты
Guru
music
Блоги
Новости
Отзывы
@IBDesignable расширение для UIButton (@IBDesignable extension for UIButton) - Swift 5
import UIKit
// Пустой класс
class
customButtons:
UIButton
{
}
// Расширение для UIButton
@IBDesignable extension
UIButton {
// Ширина границы
@IBInspectable var borderWidth
: CGFloat {
set
{
layer
.
borderWidth
= newValue
}
get
{
return layer
.borderWidth
}
}
// Радиус(Округление)
@IBInspectable var cornerRadius
: CGFloat {
set
{
layer.cornerRadius
= newValue
}
get
{
return
layer.cornerRadius
}
}
// Цвет границы
@IBInspectable var
borderColor
: UIColor? {
set
{
guard let uiColor
= newValue
else
{
return
}
layer.borderColor
= uiColor.cgColor
}
get
{
guard let color
= layer.borderColor
else
{
return
nil
}
return
UIColor
(
cgColor
: color)
}
}
}
Возврат к списку
обучись профессии будущего
Хочешь стать успешным разработчиком
приложений? Тогда добро пожаловать к нам.
Позвоните мне