我有一個UIView X
這是綠色的大小(0,0,100,100)。我需要改變綠色以清除特定部分(如矩形)中該視圖的顏色(30,30,40,40)。所以只有我可以看到X
背後的觀點。在ios中更改UIVIew中矩形的顏色?
在此先感謝
我有一個UIView X
這是綠色的大小(0,0,100,100)。我需要改變綠色以清除特定部分(如矩形)中該視圖的顏色(30,30,40,40)。所以只有我可以看到X
背後的觀點。在ios中更改UIVIew中矩形的顏色?
在此先感謝
Try this, I hope this would will help..
- (void)drawRect:(CGRect)rect {
CGRect greenRect = CGRectMake(0, 0, rect.size.width, rect.size.height/2.0);
// Fill the rectangle with grey
[[UIColor greenColor] setFill];
UIRectFill(topRect);
CGRect clearRect = CGRectMake(0, rect.size.height/2.0, rect.size.width, rect.size.height/2.0);
[[UIColor clearColor] setFill];
UIRectFill(bottomRect);
}
此處添加您的代碼,你做了什麼 – Sport
u能請記下我的問題的錯誤? – jailani