在用到UISlider时发现无法通过改变frame来改变高度,这时看到类中有一个方法:
// lets a subclass lay out the track and thumb as needed
- (CGRect)minimumValueImageRectForBounds:(CGRect)bounds;
- (CGRect)maximumValueImageRectForBounds:(CGRect)bounds;
- (CGRect)<span style="color:#ff0000;">trackRectForBounds</span>:(CGRect)bounds;
这个方法直接调用是无效的,于是重写一个继承UISlider的类FBAudioTrack,在子类中重写
- (CGRect)trackRectForBounds:(CGRect)bounds; 才有效。
#import "FBAudioTrack.h"
@implementation FBAudioTrack
- (CGRect)trackRectForBounds:(CGRect)bounds {
return CGRectMake(0, 0, ScreenWidth, 15);
}
@end