diff --git a/MVMCoreUI/Atoms/Buttons/CaretButton.swift b/MVMCoreUI/Atoms/Buttons/CaretButton.swift index 6aa4a754..47697980 100644 --- a/MVMCoreUI/Atoms/Buttons/CaretButton.swift +++ b/MVMCoreUI/Atoms/Buttons/CaretButton.swift @@ -131,4 +131,8 @@ open class CaretButton: MFCustomButton, MVMCoreUIMoleculeViewProtocol { disabledColor = UIColor.mfGet(forHex: disabledColorHex) } } + + public func needsToBeConstrained() -> Bool { + return true + } } diff --git a/MVMCoreUI/Atoms/Buttons/MFTextButton.m b/MVMCoreUI/Atoms/Buttons/MFTextButton.m index 0a72eee7..96a99a18 100644 --- a/MVMCoreUI/Atoms/Buttons/MFTextButton.m +++ b/MVMCoreUI/Atoms/Buttons/MFTextButton.m @@ -141,4 +141,8 @@ } } +- (BOOL)needsToBeConstrained { + return YES; +} + @end diff --git a/MVMCoreUI/Atoms/Views/CaretView.swift b/MVMCoreUI/Atoms/Views/CaretView.swift index eb3a4c4b..fff6181e 100644 --- a/MVMCoreUI/Atoms/Views/CaretView.swift +++ b/MVMCoreUI/Atoms/Views/CaretView.swift @@ -91,7 +91,6 @@ open class CaretView: MFView { // Default values for view. @objc open override func setAsMolecule() { - defaultState() } @@ -120,4 +119,8 @@ open class CaretView: MFView { lineWidth = lineWidthValue } } + + open override func needsToBeConstrained() -> Bool { + return true + } } diff --git a/MVMCoreUI/Atoms/Views/Label.swift b/MVMCoreUI/Atoms/Views/Label.swift index 2d53adb8..0cd77ee0 100644 --- a/MVMCoreUI/Atoms/Views/Label.swift +++ b/MVMCoreUI/Atoms/Views/Label.swift @@ -268,7 +268,6 @@ import MVMCore } }) attributedText = attributedString - } else if !MVMCoreGetterUtility.fequal(a: Float(standardFontSize), b: 0.0), let sizeObject: MFSizeObject = self.sizeObject ?? MFStyler.sizeObjectGeneric(forCurrentDevice: standardFontSize) { self.font = self.font.withSize(sizeObject.getValueBased(onSize: size)) } @@ -298,7 +297,6 @@ import MVMCore @objc public func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: DelegateObject?, additionalData: [AnyHashable: Any]?) { Label.setUILabel(self, withJSON: json, delegate: delegateObject, additionalData: additionalData) - originalAttributedString = attributedText } diff --git a/MVMCoreUI/Atoms/Views/ViewConstrainingView.m b/MVMCoreUI/Atoms/Views/ViewConstrainingView.m index 1c96040b..d14163a6 100644 --- a/MVMCoreUI/Atoms/Views/ViewConstrainingView.m +++ b/MVMCoreUI/Atoms/Views/ViewConstrainingView.m @@ -13,13 +13,16 @@ @interface ViewConstrainingView () @property (weak, nullable, nonatomic) UIView *constrainedView; -@property (strong, nullable, nonatomic) UIView *molecule; +@property (weak, nullable, nonatomic) UIView *molecule; @end @implementation ViewConstrainingView - (nullable instancetype)initWithMolecule:(nonnull UIView *)molecule { if (self = [super init]) { + if (!molecule.superview) { + [self addConstrainedView:molecule]; + } self.molecule = molecule; } return self; @@ -129,9 +132,6 @@ [super setupView]; self.translatesAutoresizingMaskIntoConstraints = NO; self.backgroundColor = [UIColor clearColor]; - if (!self.molecule.superview) { - [self addConstrainedView:self.molecule]; - } } - (void)updateView:(CGFloat)size { @@ -153,7 +153,9 @@ - (void)setAsMolecule { self.updateViewHorizontalDefaults = YES; - [self.molecule setAsMolecule]; + if ([self.molecule respondsToSelector:@selector(setAsMolecule)]) { + [self.molecule setAsMolecule]; + } } - (void)setWithJSON:(NSDictionary *)json delegateObject:(DelegateObject *)delegateObject additionalData:(NSDictionary *)additionalData {