Reputation: 917
I added button and images in m file, some how button is back to the image and not appear, i need image should be back and button should be front and should be work on click, The following code:
UIImage *myImage=[UIImage imageNamed:@"bottom_bar.png"];
UIImageView *imageView =[[UIImageView alloc] initWithImage:myImage];
imageView.frame= CGRectMake(0, 0, 320, 32);
[footerView addSubview:imageView];
UIButton *profileButton = [UIButton buttonWithType:UIButtonTypeCustom];
CGRect profileRect = CGRectMake(215.0, 0,20, 20);
[profileButton setFrame:profileRect];
[profileButton addTarget:self action:@selector(profile:) forControlEvents:UIControlEventTouchUpInside];
UIImage *profileImage = [UIImage imageNamed:@"profile_icon.png"];
[profileButton setImage:profileImage forState:UIControlStateNormal];
[footerView addSubview:profileButton];
Upvotes: 0
Views: 541
Reputation: 17535
I've checked your code. According to your code your button in front of image.Your code is perfect.Because its working proper at my end.May be mistake in your footerview.So please check it again.
Upvotes: 0
Reputation: 1623
Your code is correct in my mind. But there are some things you need to check.
1) Double check the frame size of your footerView
2) Make sure your profileButton is clickable. Since the frame of it is (215,0,20,20) it might be too small or it might be not visible inside the footerView. Change the size of it and re-check.
Upvotes: 1