I am trying to duplicate this programmatically:
I have seen there is a lot of confusion with how Apple handles this. I tried the following, but it doesn't work for me:
[buttonTop setAutoresizingMask:UIViewAutoresizingFlexibleHeight];
Any ideas where to go from here?
Update:
The code for my button is as follows:
buttonTop = [UIButton buttonWithType:UIButtonTypeCustom];
buttonTop.frame = CGRectMake(0, 0, 100, 100);
buttonTop.center = self.view.center;
buttonTop.layer.cornerRadius = buttonTop.frame.size.width / 2;
buttonTop.clipsToBounds = YES;
buttonTop.layer.masksToBounds = YES;
[buttonTop setAutoresizingMask:UIViewAutoresizingFlexibleHeight];
if (GetUserProPic){
[buttonTop sd_setImageWithURL:[NSURL URLWithString:GetUserProPic] forState:UIControlStateNormal];
[buttonTop sd_setImageWithURL:[NSURL URLWithString:GetUserProPic] forState:UIControlStateSelected];
} else {
[buttonTop setImage:[UIImage imageNamed:@"avatar_icon"] forState:UIControlStateNormal];
[buttonTop setImage:[UIImage imageNamed:@"avatar_icon"] forState:UIControlStateSelected];
}
[self.view addSubview:buttonTop];
The output looks like this:
However, I would like it to look like this: