Merge branch 'bugfix/link_line_rotate' into 'develop'
Underline didn't show when rotating See merge request BPHV_MIPS/mvm_core_ui!663
This commit is contained in:
commit
6515271b2f
@ -11,18 +11,18 @@ import UIKit
|
|||||||
|
|
||||||
@objcMembers open class Link: Button {
|
@objcMembers open class Link: Button {
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Lifecycle
|
// MARK: - Draw
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|
||||||
open override func draw(_ rect: CGRect) {
|
open override func draw(_ rect: CGRect) {
|
||||||
|
|
||||||
guard let textRect = titleLabel?.frame else { return }
|
guard let textRect = titleLabel?.frame,
|
||||||
|
let context = UIGraphicsGetCurrentContext()
|
||||||
let context = UIGraphicsGetCurrentContext()
|
else { return }
|
||||||
|
|
||||||
// Set line to the same color as the text
|
// Set line to the same color as the text
|
||||||
if let color = titleLabel?.textColor?.cgColor {
|
if let color = titleLabel?.textColor?.cgColor {
|
||||||
context?.setStrokeColor(color)
|
context.setStrokeColor(color)
|
||||||
}
|
}
|
||||||
|
|
||||||
// x should be according to the text, not the button
|
// x should be according to the text, not the button
|
||||||
@ -31,9 +31,9 @@ import UIKit
|
|||||||
// Line is 1 point below the text
|
// Line is 1 point below the text
|
||||||
let y = textRect.origin.y + textRect.size.height + 1
|
let y = textRect.origin.y + textRect.size.height + 1
|
||||||
|
|
||||||
context?.move(to: CGPoint(x: x, y: y))
|
context.move(to: CGPoint(x: x, y: y))
|
||||||
context?.addLine(to: CGPoint(x: x + textRect.size.width, y: y))
|
context.addLine(to: CGPoint(x: x + textRect.size.width, y: y))
|
||||||
context?.strokePath()
|
context.strokePath()
|
||||||
}
|
}
|
||||||
|
|
||||||
open override var intrinsicContentSize: CGSize {
|
open override var intrinsicContentSize: CGSize {
|
||||||
@ -67,16 +67,12 @@ extension Link {
|
|||||||
open override func updateView(_ size: CGFloat) {
|
open override func updateView(_ size: CGFloat) {
|
||||||
super.updateView(size)
|
super.updateView(size)
|
||||||
|
|
||||||
DispatchQueue.main.async { [weak self] in
|
var width = size
|
||||||
guard let self = self else { return }
|
if MVMCoreGetterUtility.fequal(a: Float.leastNormalMagnitude, b: Float(size)) {
|
||||||
|
width = MVMCoreUIUtility.getWidth()
|
||||||
var width = size
|
|
||||||
if MVMCoreGetterUtility.fequal(a: Float.leastNormalMagnitude, b: Float(size)) {
|
|
||||||
width = MVMCoreUIUtility.getWidth()
|
|
||||||
}
|
|
||||||
|
|
||||||
self.titleLabel?.font = MFStyler.fontB2(forWidth: width)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
titleLabel?.font = MFStyler.fontB2(forWidth: width)
|
||||||
}
|
}
|
||||||
|
|
||||||
open override func setupView() {
|
open override func setupView() {
|
||||||
|
|||||||
@ -14,9 +14,7 @@ open class LinkModel: ButtonModelProtocol, MoleculeModelProtocol, EnableableMode
|
|||||||
// MARK: - Properties
|
// MARK: - Properties
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|
||||||
public class var identifier: String {
|
public class var identifier: String { "link" }
|
||||||
return "link"
|
|
||||||
}
|
|
||||||
|
|
||||||
public var backgroundColor: Color?
|
public var backgroundColor: Color?
|
||||||
public var accessibilityIdentifier: String?
|
public var accessibilityIdentifier: String?
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user