objective-c ios uiview alpha

objective c - Vista con alfa baja-Subvista con alfa alta



objective-c ios (1)

Tengo un UIView con un alfa de .5 He agregado una subvista con un alfa de 1.

La subvista parece heredar el valor alfa del padre. ¿Hay alguna manera de hacer que la subvista sea más opaca que su vista principal?

El código se ve así:

CGRect promptFrame = CGRectMake(55, 80, 180, 50); UIView *inputPrompt = [[UIView alloc] initWithFrame: promptFrame]; [inputPrompt setBackgroundColor: [UIColor darkGrayColor]]; [inputPrompt setAlpha: .5]; inputPrompt.layer.cornerRadius = 8; inputPrompt.layer.masksToBounds = YES; CGRect fileTextFieldFrame = CGRectMake(10, 15, 150, 25); UITextField *filePrompt = [[UITextField alloc] initWithFrame: fileTextFieldFrame]; [filePrompt setBorderStyle:UITextBorderStyleRoundedRect]; [filePrompt setClearButtonMode:UITextFieldViewModeWhileEditing]; [filePrompt setBackgroundColor: [UIColor whiteColor]]; [filePrompt setAlpha: 1];

El resultado se ve así:

Me gustaría poder ver el botón debajo de UIView gris pero no debajo de UITextField blanco. ¿Cómo hago esto?


Configure el alfa del color de fondo del inputPrompt no su alfa directamente.

[inputPrompt setBackgroundColor:[[UIColor darkGrayColor] colorWithAlphaComponent:0.5]]; //[inputPrompt setAlpha: .5];