self.refreshControl.tintColor = [UIColor blueColor];//this just only change it color
可以將下拉箭頭更改爲某個圖片或其他形狀嗎?怎麼樣?關於UIRefreshControl如何更改IOS6.0中的默認下拉箭頭
非常感謝!
self.refreshControl.tintColor = [UIColor blueColor];//this just only change it color
可以將下拉箭頭更改爲某個圖片或其他形狀嗎?怎麼樣?關於UIRefreshControl如何更改IOS6.0中的默認下拉箭頭
非常感謝!
沒有。你只能改變箭頭的顏色,而不能改變箭頭的顏色。如果你想這樣做,請file an enhancement request,它會被考慮。
當然,你也可以自己寫一個,或者使用一個開源的變種。
隱藏的API版本(在我的實際代碼中,maskImage是UIImage上的一個類別)。我不知道蘋果是否會拒絕這一點。
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
這使得獨角獸和小貓痛哭的血淚。 **請勿使用此代碼**。它依賴於'UIRefreshControl'的*實現細節*,可以在將來的任何時候改變。唯一保證的是* API *將是一致的。 –
它不會崩潰。發生的最糟糕的事情是蘋果改變了一些事情,而你的箭頭是錯誤的顏色 - 而且很可能,他們將有一個API來做到這一點。 – xtravar
你很可能會被'UIRefreshControl'類別拒絕,因爲它是'_contentView'方法。 –
是啊,感謝ü....一些開源易於使用,它的支持左,右,上,下拖,感謝 – Dark