自從iOS 7 alpha版本以來,我一直在爲此而苦苦掙扎。首先,我認爲這是一個錯誤的alpha,但它仍然在發生,所以我做錯了什麼。CoreGraphics無法在iOS 7.0模擬器上工作
我正在繪製像單元格背景等CG應用程序,但在iOS 7中不顯示。
爲例:
@interface NewManagerCell : UITableViewCell
@end
@implementation NewManagerCell
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
//some initialization code here
}
return self;
}
- (void)drawRect:(CGRect)rect {
CGContextRef context = UIGraphicsGetCurrentContext();
CGRect bounds = self.bounds;
bounds.origin.y += 5; //inter-cell spacing
bounds.size.height -= 5;
CGFloat mx = CGRectGetMinX(bounds);
CGFloat Mx = CGRectGetMaxX(bounds);
CGFloat my = CGRectGetMinY(bounds);
CGFloat cy = CGRectGetMinY(bounds)+CGRectGetHeight(bounds)*.375;
CGFloat My = CGRectGetMaxY(bounds);
CGContextBeginPath(context);
CGContextMoveToPoint(context, mx, cy);
CGContextAddLineToPoint(context, mx+cy-my, my);
CGContextAddLineToPoint(context, Mx-cy+my, my);
CGContextAddLineToPoint(context, Mx, cy);
CGContextAddLineToPoint(context, Mx, My);
CGContextAddLineToPoint(context, mx, My);
CGContextAddLineToPoint(context, mx, cy);
CGContextSetFillColorWithColor(context, [[UIColor colorWithPatternImage:[UIImage imageNamed:@"cell-pattern"]] CGColor]);
CGContextFillPath(context);
mx += 4+CGRectGetWidth(bounds)/4-CGRectGetHeight(bounds)*.375/16;
Mx -= 4;
my += 4;
My -= 4;
cy += 2;
CGMutablePathRef path = CGPathCreateMutable();
CGContextBeginPath(context);
CGPathMoveToPoint(path, &CGAffineTransformIdentity, mx, my);
CGPathAddLineToPoint(path, &CGAffineTransformIdentity, Mx-(cy-my), my);
CGPathAddLineToPoint(path, &CGAffineTransformIdentity, Mx, cy);
CGPathAddLineToPoint(path, &CGAffineTransformIdentity, Mx, My);
CGPathAddLineToPoint(path, &CGAffineTransformIdentity, mx, My);
CGPathAddLineToPoint(path, &CGAffineTransformIdentity, mx, my);
CGContextAddPath(context, path);
CGContextSetRGBFillColor(context, 1, 1, 1, 1);
CGContextFillPath(context);
CGContextAddPath(context, path);
CGContextSetRGBStrokeColor(context, .69, .69, .69, 1);
CGContextStrokePath(context);
CGPathRelease(path);
}
@end
,在iOS版的前7味的任何工作,現在停止了工作。有沒有人對發生的事情有任何線索?
可能的副本[subclassed UITableViewCell - backgroundView涵蓋了我在drawRect中做的任何事情](http://stackoverflow.com/questions/3527925/subclassed-uitableviewcell-backgroundview-covers-up-anything-i-do-in-拉拔) – StilesCrisis