|
//
// FFSheetActionCell.swift
// FFAlert
//
// Created by FFIB on 2017/11/17.
// Copyright © 2017年 FFIB. All rights reserved.
//
import UIKit
class FFSheetActionCell: UITableViewCell {
var label = UILabel()
func setInfo(alertAction: FFAlertAction) {
addSubview(label)
label.translatesAutoresizingMaskIntoConstraints = false
label.attributedText = alertAction.attributedTitle
label.backgroundColor = alertAction.backgroundColor
label.textAlignment = .center
let actionEdgInsets = alertAction.contentEdgInsets ?? UIEdgeInsets.zero
NSLayoutConstraint.activate(
[NSLayoutConstraint(item: label, attribute: .leading,
relatedBy: .equal,
toItem: self, attribute: .leading,
multiplier: 1, constant: actionEdgInsets.left),
NSLayoutConstraint(item: label, attribute: .trailing,
relatedBy: .equal,
toItem: self, attribute: .trailing,
multiplier: 1, constant: -actionEdgInsets.right),
NSLayoutConstraint(item: label, attribute: .top,
relatedBy: .equal,
toItem: self, attribute: .top,
multiplier: 1, constant: actionEdgInsets.top),
NSLayoutConstraint(item: label, attribute: .bottom,
relatedBy: .equal,
toItem: self, attribute: .bottom,
multiplier: 1, constant: -actionEdgInsets.bottom - 6)]
)
}
}
|