Comment redimensionner une UISwitch?

J'ai fait un personnalisé UISwitch (à partir de ce post). Mais le problème est, à mon habitude, les textes sont un peu long. Est-il possible de redimensionner l'interrupteur? [J'ai essayé setBounds, n'a pas de travail]

Edit:

Voici le code que j'ai utilisé:

@interface CustomUISwitch : UISwitch    
- (void) setLeftLabelText: (NSString *) labelText;
- (void) setRightLabelText: (NSString *) labelText;    
@end

@implementation CustomUISwitch

- (UIView *) slider 
{ 
    return [[self subviews] lastObject]; 
}
- (UIView *) textHolder 
{ 
    return [[[self slider] subviews] objectAtIndex:2]; 
}
- (UILabel *) leftLabel 
{ 
    return [[[self textHolder] subviews] objectAtIndex:0]; 
}
- (UILabel *) rightLabel 
{ 
    return [[[self textHolder] subviews] objectAtIndex:1]; 
}
- (void) setLeftLabelText: (NSString *) labelText 
{ 
    [[self leftLabel] setText:labelText]; 
}
- (void) setRightLabelText: (NSString *) labelText 
{ 
    [[self rightLabel] setText:labelText]; 
}
@end

mySwitch = [[CustomUISwitch alloc] initWithFrame:CGRectZero];

//Tried these, but did not work
//CGRect aFrame = mySwitch.frame;
//aFrame.size.width = 200;
//aFrame.size.height = 100;
//mySwitch.frame = aFrame;

[mySwitch setLeftLabelText: @"longValue1"];
[mySwitch setRightLabelText: @"longValue2"];
  • Êtes-vous à l'aide de UISwitch (à partir de votre sujet) ou UICustomSwitch (à partir de votre lien)? Le UICustomSwitch classe est en fait un UISlider.
  • mais il hérite UISwitch, comment peut-il être un curseur?
  • UICustomSwitch hérite de UISlider. Lequel utilisez-vous? Votre code dit CustomUISwitch, votre sujet dit UISwitch, mais le lien que vous avez donné des points à un UICustomSwitch mise en œuvre? Nous ne pouvons pas répondre à votre question, très bien, à moins que vous dire lequel des 3 vous vraiment le but!
  • Désolé, Maintenant, j'ai ajouté le code.
  • mshsayem, je pense que vous devriez prendre en considération la modification de la sélectionné réponse correcte.
InformationsquelleAutor mshsayem | 2010-06-01