changed constraints for backgroundImageView and updated frames for CAlayers
This commit is contained in:
parent
87a0198e24
commit
f528b3cd62
@ -240,7 +240,12 @@ open class TileContainerBase<PaddingType: DefaultValuing>: Control where Padding
|
||||
|
||||
heightConstraint = layoutGuide.heightAnchor.constraint(equalToConstant: 0)
|
||||
|
||||
backgroundImageView.pin(layoutGuide)
|
||||
backgroundImageView
|
||||
.pinTop(layoutGuide.topAnchor)
|
||||
.pinLeading(layoutGuide.leadingAnchor)
|
||||
.pinTrailing(layoutGuide.trailingAnchor)
|
||||
.pinBottom(layoutGuide.bottomAnchor, 0, .dragThatCanResizeScene)
|
||||
|
||||
backgroundImageView.isUserInteractionEnabled = false
|
||||
backgroundImageView.isHidden = true
|
||||
|
||||
@ -257,6 +262,7 @@ open class TileContainerBase<PaddingType: DefaultValuing>: Control where Padding
|
||||
layer.cornerRadius = cornerRadius
|
||||
backgroundImageView.layer.cornerRadius = cornerRadius
|
||||
highlightView.layer.cornerRadius = cornerRadius
|
||||
clipsToBounds = true
|
||||
}
|
||||
|
||||
/// Resets to default settings.
|
||||
@ -327,7 +333,14 @@ open class TileContainerBase<PaddingType: DefaultValuing>: Control where Padding
|
||||
}
|
||||
applyBackgroundEffects()
|
||||
}
|
||||
|
||||
|
||||
/// Used to update frames for the added CAlayers to our view
|
||||
open override func layoutSubviews() {
|
||||
super.layoutSubviews()
|
||||
dropShadowLayers?.forEach { $0.frame = bounds }
|
||||
gradientLayers?.forEach { $0.frame = bounds }
|
||||
}
|
||||
|
||||
//--------------------------------------------------
|
||||
// MARK: - Public Methods
|
||||
//--------------------------------------------------
|
||||
|
||||
@ -349,6 +349,7 @@ open class Tilelet: TileContainerBase<Tilelet.Padding> {
|
||||
If a Tilelet has only a Title or a Subtitle, then the Title or Subtitle is truncated and appended with an ellipsis when there is not enough space to display the full text.
|
||||
If a Tilelet has both Title and Subtitle, then only Subtitle will be truncated.
|
||||
If a Tilelet has Badge, Title and Subtitle, then Subtitle will be truncated first and Badge will be truncated second. Title will be truncated last (lowest priority).
|
||||
Atleast one line text based on priority
|
||||
Minimum bottom space below Badge is 4px; less than 4px results in truncation.
|
||||
*/
|
||||
let labelPriority = UILayoutPriority.defaultHigh.rawValue
|
||||
@ -576,8 +577,5 @@ open class Tilelet: TileContainerBase<Tilelet.Padding> {
|
||||
extension Label {
|
||||
|
||||
///To calculate label single line height
|
||||
fileprivate var minimumLineHeight: CGFloat {
|
||||
guard let text, !text.isEmpty, let attributes = attributedText?.attributes(at: 0, longestEffectiveRange: nil, in: NSRange(location: 0, length: attributedText?.string.count ?? 0))[.paragraphStyle] as? NSParagraphStyle else { return font.lineHeight }
|
||||
return attributes.minimumLineHeight
|
||||
}
|
||||
fileprivate var minimumLineHeight: CGFloat { textStyle.lineHeight }
|
||||
}
|
||||
|
||||
@ -50,7 +50,6 @@ extension ViewProtocol where Self: UIView {
|
||||
shadowLayer.shadowPath = shadowPath.cgPath
|
||||
shadowLayer.frame = bounds
|
||||
shadowLayer.position = .init(x: bounds.midX, y: bounds.midY)
|
||||
shadowLayer.backgroundColor = backgroundColor?.cgColor
|
||||
shadowLayer.cornerRadius = layer.cornerRadius
|
||||
shadowLayer.shadowColor = config.shadowColorConfiguration.getColor(self).cgColor
|
||||
shadowLayer.shadowOpacity = Float(config.shadowOpacityConfiguration.value(for: self))
|
||||
@ -86,4 +85,8 @@ extension ViewProtocol where Self: UIView {
|
||||
func removeGradientLayer() {
|
||||
layer.sublayers?.removeAll { $0.name == "gradientLayer" }
|
||||
}
|
||||
|
||||
//Helper variables to get gradient & shadow layers. These are exposed to update frame of layers when view's frame is updated.
|
||||
var dropShadowLayers: [CALayer]? { layer.sublayers?.filter { $0.name == "dropShadowLayer" } }
|
||||
var gradientLayers: [CAGradientLayer]? { layer.sublayers?.filter { $0.name == "gradientLayer" } as? [CAGradientLayer] }
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user