1.設(shè)置背景半透明:
在開發(fā)過程中,很多需要設(shè)置控件的透明度,下面提供幾種設(shè)置控件透明度的方法
UIView *titlesView = [[UIView alloc] init];
// 設(shè)置半透明背景色
titlesView.backgroundColor = [[UIColor whiteColor] colorWithAlphaComponent:0.5];
// titlesView.backgroundColor = [UIColor colorWithWhite:1.0 alpha:0.5];
// titlesView.backgroundColor = [UIColor colorWithRed:1.0 green:1.0 blue:1.0 alpha:0.5];
// 注意:子控件會繼承父控件設(shè)置的alpha透明度,如果在titlesView添加一個label的話,label的透明度會跟隨titlesView的透明變化
// titlesView.alpha = 0.5;
titlesView.frame = CGRectMake(0, 64, [UIScreen mainScreen].bounds.size.width, 35);