UISlider自定义高度
2016-01-08 14:42
489 查看
在用到UISlider时发现无法通过改变frame来改变高度,这时看到类中有一个方法:
[objc] view
plaincopy
// 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; 才有效。
[objc] view
plaincopy
#import "FBAudioTrack.h"
@implementation FBAudioTrack
- (CGRect)trackRectForBounds:(CGRect)bounds {
return CGRectMake(0, 0, ScreenWidth, 15);
}
@end
[objc] view
plaincopy
// 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; 才有效。
[objc] view
plaincopy
#import "FBAudioTrack.h"
@implementation FBAudioTrack
- (CGRect)trackRectForBounds:(CGRect)bounds {
return CGRectMake(0, 0, ScreenWidth, 15);
}
@end
相关文章推荐
- UIAlertController中添加DatePicker
- It is indirectly referenced from required class file ... could not find class......
- easyUI tree以及tab的创建以及应用
- bluedroid 代码框架
- UITableView使用小结(滚动到顶部、获取cell、cell选中状态、刷新cell或者section)
- UVa 12100 - Printer Queue【队列和优先队列】
- Android 更新UI的两种方法——handler和runOnUiThread()
- Android Build类
- 【LeetCode】Repeated DNA Sequences 解题报告
- Request与Response常用方法总结
- Android Contacts (一)ContentResolver query 参数详解
- UIPickerView组件的使用之——省市联动
- Map对value进行排序
- org.hibernate.exception.JDBCConnectionException: could not execute query
- apktool,dex2jar,jd-gui简单使用与实战
- 如何在UICollectionView reloadData后找到的某个cell
- Axure VS Mockplus VS Balsamiq - 原型图设计工具对比
- Android仿iOS7的UISegmentedControl 分段
- 1.3.0 REQUEST ROUTING(请求路由)
- gradle:build.number 获取不到导致的error