constraining for stack

This commit is contained in:
Pfeil, Scott Robert 2019-04-24 16:14:22 -04:00
parent 1573e57f2c
commit 8a349ae16f
5 changed files with 19 additions and 8 deletions

View File

@ -131,4 +131,8 @@ open class CaretButton: MFCustomButton, MVMCoreUIMoleculeViewProtocol {
disabledColor = UIColor.mfGet(forHex: disabledColorHex) disabledColor = UIColor.mfGet(forHex: disabledColorHex)
} }
} }
public func needsToBeConstrained() -> Bool {
return true
}
} }

View File

@ -141,4 +141,8 @@
} }
} }
- (BOOL)needsToBeConstrained {
return YES;
}
@end @end

View File

@ -91,7 +91,6 @@ open class CaretView: MFView {
// Default values for view. // Default values for view.
@objc open override func setAsMolecule() { @objc open override func setAsMolecule() {
defaultState() defaultState()
} }
@ -120,4 +119,8 @@ open class CaretView: MFView {
lineWidth = lineWidthValue lineWidth = lineWidthValue
} }
} }
open override func needsToBeConstrained() -> Bool {
return true
}
} }

View File

@ -268,7 +268,6 @@ import MVMCore
} }
}) })
attributedText = attributedString attributedText = attributedString
} else if !MVMCoreGetterUtility.fequal(a: Float(standardFontSize), b: 0.0), let sizeObject: MFSizeObject = self.sizeObject ?? MFStyler.sizeObjectGeneric(forCurrentDevice: standardFontSize) { } 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)) 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]?) { @objc public func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: DelegateObject?, additionalData: [AnyHashable: Any]?) {
Label.setUILabel(self, withJSON: json, delegate: delegateObject, additionalData: additionalData) Label.setUILabel(self, withJSON: json, delegate: delegateObject, additionalData: additionalData)
originalAttributedString = attributedText originalAttributedString = attributedText
} }

View File

@ -13,13 +13,16 @@
@interface ViewConstrainingView () @interface ViewConstrainingView ()
@property (weak, nullable, nonatomic) UIView *constrainedView; @property (weak, nullable, nonatomic) UIView *constrainedView;
@property (strong, nullable, nonatomic) UIView <MVMCoreUIMoleculeViewProtocol>*molecule; @property (weak, nullable, nonatomic) UIView <MVMCoreUIMoleculeViewProtocol>*molecule;
@end @end
@implementation ViewConstrainingView @implementation ViewConstrainingView
- (nullable instancetype)initWithMolecule:(nonnull UIView <MVMCoreUIMoleculeViewProtocol>*)molecule { - (nullable instancetype)initWithMolecule:(nonnull UIView <MVMCoreUIMoleculeViewProtocol>*)molecule {
if (self = [super init]) { if (self = [super init]) {
if (!molecule.superview) {
[self addConstrainedView:molecule];
}
self.molecule = molecule; self.molecule = molecule;
} }
return self; return self;
@ -129,9 +132,6 @@
[super setupView]; [super setupView];
self.translatesAutoresizingMaskIntoConstraints = NO; self.translatesAutoresizingMaskIntoConstraints = NO;
self.backgroundColor = [UIColor clearColor]; self.backgroundColor = [UIColor clearColor];
if (!self.molecule.superview) {
[self addConstrainedView:self.molecule];
}
} }
- (void)updateView:(CGFloat)size { - (void)updateView:(CGFloat)size {
@ -153,7 +153,9 @@
- (void)setAsMolecule { - (void)setAsMolecule {
self.updateViewHorizontalDefaults = YES; 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 { - (void)setWithJSON:(NSDictionary *)json delegateObject:(DelegateObject *)delegateObject additionalData:(NSDictionary *)additionalData {