self.refreshControl.tintColor = [UIColor blueColor];//this just only change it color
我可以将下拉箭头更改为某些图片或其他形状吗?怎么样?
非常感谢!
答案 0 :(得分:3)
不。您只能更改箭头的颜色,而不能更改箭头本身。如果您希望能够这样做,请file an enhancement request并考虑它。
当然,您也可以自己编写一个,或使用开源变体。
答案 1 :(得分:0)
隐藏的API版本(在我的实际代码中,maskImage是UIImage上的一个类别)。我不知道Apple是否会拒绝这一点。
static UIImage *maskImage(UIImage *image, UIColor *color) {
UIImage *retval;
CGRect rect = CGRectMake(0, 0, image.size.width, image.size.height);
UIGraphicsBeginImageContextWithOptions(image.size, NO, image.scale);
[color set];
CGContextFillRect(UIGraphicsGetCurrentContext(), rect);
[image drawAtPoint:CGPointZero blendMode:kCGBlendModeDestinationIn alpha:1];//
retval = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return retval;
}
@protocol UIRefreshHacking <NSObject>
-(UIImageView*)arrow;
@end
@interface UIRefreshControl (GetAtContentView)
-(UIView<UIRefreshHacking>*)_contentView;
@end
@implementation UIRefreshControl (ChangeArrowColor)
-(BOOL)setArrowColor:(UIColor *)arrowColor {
if(![self respondsToSelector:@selector(_contentView)]) {
return NO;
}
UIView<UIRefreshHacking> *cv = [self _contentView];
if(![cv respondsToSelector:@selector(arrow)]) {
return NO;
}
UIImageView *iv = [cv arrow];
iv.image = maskImage(iv.image, arrowColor);
return YES;
}
@end