Estou tentando criar um botao que possa atender 2 orientações. mas quando está em modo horizontal o botão fica para a direita. Alguém tem alguma ideia de como fazer isso?
Meu codigo é esse:
Code:
+(UIBarButtonItem*) createHomeBarButton:(id)target selector:(SEL)selector {
UIButton *homeButton = [UIButton buttonWithType:UIButtonTypeCustom];
[homeButton setImage:[UIImage imageNamed:@"bt_navHome.png"] forState:UIControlStateNormal];
[homeButton sizeToFit];
homeButton.imageView.autoresizingMask = UIViewAutoresizingFlexibleHeight;
homeButton.imageView.contentMode = UIViewContentModeScaleAspectFit;
[homeButton setAdjustsImageWhenHighlighted:YES];
[homeButton setReversesTitleShadowWhenHighlighted:YES];
homeButton.backgroundColor = [UIColor clearColor];
[homeButton addTarget:target action:selector forControlEvents:UIControlEventTouchUpInside];
homeButton.contentMode = UIViewContentModeScaleAspectFit;
homeButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
homeButton.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
homeButton.autoresizingMask = UIViewAutoresizingFlexibleHeight;
UIBarButtonItem *homeBarButton = [[UIBarButtonItem alloc] initWithCustomView:homeButton];
return [homeBarButton autorelease];
}
e abaixo é como está sendo exibido:
e aqui na horizontal: