0
我有以下的方法,由於某種原因不顯示圖像:生成一個UIView與圖像
- (void)drawRect:(CGRect)rect
{
float cornerRadius = self.bounds.size.width/RADIUS_RATIO;
UIBezierPath *roundedRect = [UIBezierPath bezierPathWithRoundedRect:self.bounds cornerRadius:cornerRadius];
[roundedRect addClip];
[[UIColor whiteColor] setFill];
UIRectFill(self.bounds);
[[UIColor blackColor] setStroke];
[roundedRect stroke];
CGRect imageRect = CGRectInset(self.bounds,
self.bounds.size.width * 0.5,
self.bounds.size.height * 0.5);
if (self.faceUp)
{
UIImage *cardFace = [UIImage imageNamed:[NSString stringWithFormat:
@"%@%@.png",[self rankAsStrings],self.suit]];
if (cardFace)
{
NSLog(@"%@%@.png",[self rankAsStrings],self.suit);
[cardFace drawInRect:imageRect];
} else {
NSLog(@"No Image Found: %@%@.png",[self rankAsStrings],self.suit);
}
} else {
[[UIImage imageNamed:@"Back.png"] drawInRect:imageRect];
}
}
有人可以提供一些線索這光?
P.S.圖像存在,我確實得到了「NSLog(@」%@%@。png「,[self rankAsStrings],self.suit);」消息在控制檯中。
TIA
感謝一大堆...森林這裏樹木的情況! –