我有一個UIView W/C我返回作爲視圖在我viewForHeaderInSection。現在,我想在視圖的右下方製作一個小的透明正方形,以便可以看到單元格。我怎樣才能實現這樣的事情?我需要使用這個CGContextSetBlendMode嗎?任何人都可以闡明這一點。使UIView的一部分變得透明
0
A
回答
0
該視圖作爲子視圖插入到SwitchViewController.view中。所以,它們將始終出現在SwitchViewControllers視圖的上方。另一個視圖被刪除,一次只會出現一個視圖
例如,這裏
[yellowViewController.view removeFromSuperview];
[self.view insertSubview:blueViewController.view atIndex:0];
觀點似乎在默認情況下它的子視圖的背後,
insertSubview:atIndex:
不能把它認爲自己的背後,作爲一個視圖不會在自己的子視圖列表中包含。
+0
讓我知道如果這個代碼工作..我有同樣的概率,我已經通過堆棧解決 – 2012-02-27 09:33:54
0
這是一個UIView子類的解決方案。爲了這個工作,你必須保留superviews backgroundColor屬性爲nil女巫是默認值。如果此UIView子類在故事板中,請確保在屬性檢查器中將背景色設置爲「清除顏色」。
- (void)drawRect:(CGRect)rect {
CGContextRef ctx = UIGraphicsGetCurrentContext();
UIColor *blackBackgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:1];
CGContextSetFillColorWithColor(ctx, blackBackgroundColor.CGColor);
CGContextFillRect(ctx, rect);
CGRect transparentPart = CGRectMake(10, 10, 120, 80);
CGContextClearRect(ctx, transparentPart);
}
0
CALayer *layer = [[CALayer alloc] init];
[layer setFrame:yourBoundsInView];
[[yourView layer] setMask:layer];
或重寫drawRect方法,並在末尾添加的代碼以下行
UIBezierPath *seeThrough = [UIBezierPath bezierPathWithRect:seeThroughRect];
[[UIColor colorWithWhite:1 alpha:0] set];
[seeThrough fillWithBlendMode:kCGBlendModeSourceIn alpha:1];
相關問題
- 1. 使UIView的一部分透明
- 2. UIView透明漸變
- 3. 使UIView透明
- 4. iPhone自定義UIView部分透明
- 5. DAE模型的一部分變得透明
- 6. 使UIImageView的一部分透明
- 7. 使圖像的一部分透明
- 8. 使圖像的一部分透明
- 9. 使用backgroundColor繪製部分透明的UIView
- 10. 使圖像變得透明
- 11. 在Pygame中,爲什麼我無法使圖像的一部分變得透明?
- 12. JDialog:使部分透明
- 13. 頂部檢測透明的UIView倒是
- 14. UIActivityViewController的SMS窗口變得部分透明
- 15. 使UIView前景透明
- 16. UIbutton部分透明?
- 17. JFrame部分透明
- 18. 具有非透明內容的另一個透明UIView的透明視圖?
- 19. UIView背景透明
- 20. 透明部分的視圖?
- 21. TableViewController中的透明部分
- 22. 創建一個透明的UIview
- 23. 使div的文本部分透明
- 24. 狀態欄變得透明
- 25. RatingBar變得半透明
- 26. 繪製透明NSImage中使得透明
- 27. 當使用windowActionBarOverlay時,ActionBarSherlock變得透明
- 28. 如何使UISegmentedcontrol變得透明?
- 29. 使用CSS/Javascript使部分透明度變暗背景圖像
- 30. 製作部分透明
你可以把它全部是透明的,並添加一個UIImageView作爲與具有一個PNG背景部分透明。 – 2012-02-27 09:28:39
你可以從結果中添加藍圖嗎?很難形象化。 – mariusLAN 2012-02-27 09:29:08