有誰知道如何使UISegmentedControl
透明?我設置了ViewController
的背景主題和文本顏色。我目前正在使用此代碼ViewDidLoad
:如何使UISegmentedcontrol變得透明?
segGame.backgroundColor = [UIColor colorWithWhite:1.0 alpha:0.4];
有什麼辦法來設置segmentedControl
編程或廈門國際銀行的?
有誰知道如何使UISegmentedControl
透明?我設置了ViewController
的背景主題和文本顏色。我目前正在使用此代碼ViewDidLoad
:如何使UISegmentedcontrol變得透明?
segGame.backgroundColor = [UIColor colorWithWhite:1.0 alpha:0.4];
有什麼辦法來設置segmentedControl
編程或廈門國際銀行的?
您必須製作自定義段控制器。
將此代碼寫入您的ViewDidLoad
方法。沒問題
請試試這個:
// Set set segmentControl background to transparent
CGRect rect = CGRectMake(0, 0, 1, 1);
UIGraphicsBeginImageContext(rect.size);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetFillColorWithColor(context, [[UIColor clearColor] CGColor]);
CGContextFillRect(context, rect);
UIImage *transparentImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
[segmentControl setBackgroundImage:transparentImage forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
[segmentControl setDividerImage:transparentImage forLeftSegmentState:UIControlStateNormal rightSegmentState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
如果使用圖像這一塊,那麼它看起來比背景透明度
[segmentControl setDividerImage:[UIImage new] forLeftSegmentState:UIControlStateNormal rightSegmentState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
[segmentControl setBackgroundImage:[UIImage new] forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
更好試試這一個。
故事板是你想做的事非常方便。看看screnshot。
有沒有什麼辦法可以在xib中設置segmentedControl透明? – 2014-09-27 11:19:16
點擊此鏈接:http://www.framewreck.net/2010/07/custom-tintcolor-for-each-segment-of.html – 2014-09-27 12:17:33
xib它已經與透明。哪個xcode你使用? – 2014-09-27 12:19:05