0
我有子類的UITextField
,以便有旁邊的文本字段中的圖標,這裏是代碼:PNG圖像顯示在IOS半透明
iconView = [UIImageView new];
self.textField = [UITextField new];
self.textField.borderStyle = UITextBorderStyleNone;
self.textField.textColor = [UIColor whiteColor];
self.layer.cornerRadius = 5;
self.layer.borderWidth = 1;
self.layer.borderColor = TEXTFIELD_BORDER_COLOR;
self.backgroundColor = [UIColor clearColor];
self.textField.backgroundColor = [UIColor clearColor];
//iconView.backgroundColor = [UIColor clearColor];
[self.textField setTranslatesAutoresizingMaskIntoConstraints:NO];
[iconView setTranslatesAutoresizingMaskIntoConstraints:NO];
[self setTranslatesAutoresizingMaskIntoConstraints:NO];
[self addSubview:iconView];
[self addSubview:self.textField];
[self setUpConstraints];
當我設置的圖像,這不裏面有任何的透明度,一切正常,但當我設置透明度,我得到了一半,可見的圖像。 以下是圖像的兩個例子,第一個顯示細膩,第二個是隱約可見:
檢查'iconView'的alpha值是否爲1,或者在視圖中添加'iconView.alpha = 1'之前將其設置爲1。 – rptwsthi