iOS:UIImageView resize when one dimension is just or most,anothor is fit.
This commit is contained in:
parent
870a7e74af
commit
2e0bbcfb89
@ -21,17 +21,14 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#import "DoricImageNode.h"
|
#import "DoricImageNode.h"
|
||||||
#import "Doric.h"
|
|
||||||
#import "YYWebImage.h"
|
#import "YYWebImage.h"
|
||||||
|
#import "DoricExtensions.h"
|
||||||
|
#import "DoricUtil.h"
|
||||||
|
|
||||||
@interface DoricImageView : YYAnimatedImageView
|
@interface DoricImageView : YYAnimatedImageView
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@implementation DoricImageView
|
@implementation DoricImageView
|
||||||
|
|
||||||
- (CGSize)sizeThatFits:(CGSize)size {
|
|
||||||
return [self sizeThatFits:size];
|
|
||||||
}
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@interface DoricImageNode ()
|
@interface DoricImageNode ()
|
||||||
|
@ -169,10 +169,23 @@ - (void)setFrame {
|
|||||||
- (void)measureUndefinedContent:(CGSize)targetSize {
|
- (void)measureUndefinedContent:(CGSize)targetSize {
|
||||||
CGSize measuredSize = [self.view sizeThatFits:targetSize];
|
CGSize measuredSize = [self.view sizeThatFits:targetSize];
|
||||||
if (self.widthSpec == DoricLayoutFit) {
|
if (self.widthSpec == DoricLayoutFit) {
|
||||||
self.measuredWidth = measuredSize.width + self.paddingLeft + self.paddingRight;
|
if ([self.view isKindOfClass:[UIImageView class]]
|
||||||
|
&& self.heightSpec != DoricLayoutFit && measuredSize.height > 0) {
|
||||||
|
self.measuredWidth = measuredSize.width / measuredSize.height * self.measuredHeight
|
||||||
|
+ self.paddingLeft + self.paddingRight;
|
||||||
|
} else {
|
||||||
|
self.measuredWidth = measuredSize.width + self.paddingLeft + self.paddingRight;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (self.heightSpec == DoricLayoutFit) {
|
if (self.heightSpec == DoricLayoutFit) {
|
||||||
self.measuredHeight = measuredSize.height + self.paddingTop + self.paddingBottom;
|
if ([self.view isKindOfClass:[UIImageView class]]
|
||||||
|
&& self.widthSpec != DoricLayoutFit && measuredSize.width > 0) {
|
||||||
|
self.measuredHeight = measuredSize.height / measuredSize.width * self.measuredWidth
|
||||||
|
+ self.paddingTop + self.paddingBottom;
|
||||||
|
} else {
|
||||||
|
self.measuredHeight = measuredSize.height + self.paddingTop + self.paddingBottom;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user