Objetivo C Setter anulando en Swift
Necesito anular la configuración de la propiedad resaltada UIViews en mi subclase UIButton personalizada;
C objetivo
@property(nonatomic,getter=isHighlighted) BOOL highlighted;
anulado así
- (void) setHighlighted:(BOOL)highlighted {
[super setHighlighted:highlighted];
if (highlighted) {
self.backgroundColor = UIColorFromRGB(0x387038);
}
else {
self.backgroundColor = UIColorFromRGB(0x5bb75b);
}
[super setHighlighted:highlighted];
}
Rápido
var highlighted: Bool
Lo intenté:
var highlighted: Bool {
get{ return false }
set {
if highlighted {
self.backgroundColor = UIColor.whiteColor()
//Error "Use unresolved identifier 'self'"
I can't set the background color from value type in here
, can't call self.backgroundColor in this value type ,
can't call super too because this is a value type , doesn't work
}
}
}
Cómo y dónde debe implementar este método en Swift para obtener el mismo resultado. ¿alguna idea?