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