diff --git a/AutoCat2/Components/PlateView/PlateView.swift b/AutoCat2/Components/PlateView/PlateView.swift index 4181156..14bb9df 100644 --- a/AutoCat2/Components/PlateView/PlateView.swift +++ b/AutoCat2/Components/PlateView/PlateView.swift @@ -27,6 +27,12 @@ class PlateView: UIView { } } + var fontSize: CGFloat = 10 { + didSet { + self.layoutSubviews() + } + } + override init(frame: CGRect) { super.init(frame: frame) setup() @@ -124,15 +130,20 @@ class PlateView: UIView { } override var intrinsicContentSize: CGSize { - guard self.bounds.width != 0 || self.bounds.height != 0 else { - return CGSize.zero - } - - let curAspectRatio = self.bounds.height/self.bounds.width - if curAspectRatio >= PlateView.aspectRatio { - return CGSize(width: self.bounds.width, height: self.bounds.width*PlateView.aspectRatio) - } else { - return CGSize(width: self.bounds.height/PlateView.aspectRatio, height: self.bounds.height) - } + + let height = fontSize/1.1 + 4 + let width = height/PlateView.aspectRatio + return CGSize(width: width, height: height) + +// guard self.bounds.width != 0 || self.bounds.height != 0 else { +// return CGSize.zero +// } +// +// let curAspectRatio = self.bounds.height/self.bounds.width +// if curAspectRatio >= PlateView.aspectRatio { +// return CGSize(width: self.bounds.width, height: self.bounds.width*PlateView.aspectRatio) +// } else { +// return CGSize(width: self.bounds.height/PlateView.aspectRatio, height: self.bounds.height) +// } } }