UIProgressView 自定义高度问题

@interface LDProgressView : UIProgressView

@property(nonatomic, assign) CGFloat customHeight;

@end

@implementation LDProgressView

- (void)setFrame:(CGRect)frame {
    [super setFrame:frame];
    
    _customHeight = frame.size.height;
}

- (void)setCustomHeight:(CGFloat)customHeight {
    _customHeight = customHeight;
    
    [self setNeedsLayout];
    [self layoutIfNeeded];
}

- (CGSize)sizeThatFits:(CGSize)size {
    CGSize superSize = [super sizeThatFits:size];
    return CGSizeMake(superSize.width, self.customHeight);
}
@end

推荐阅读更多精彩内容