Yuchen
Yuchen

Reputation: 33076

Bring a UIView to the front for `UICollectionViewController`

We have a photo browser which we can use to select multiple images and do something with them. However, the process is slow. Therefore, we want to show a progress view on top of the UICollection View when the user hit import button.

However, it seems that I cannot arrange the order of the view in interface builder (in storyboard). I also tried the following bringSubviewToFront function in code and it is not working either.

[self.view bringSubviewToFront:self.progressView];

Any idea how to do this?

BTW, in the following screenshot, the highlighted View is linked to:

@property (weak, nonatomic) IBOutlet UIView *progressView; 

enter image description here

Edit:

I am pretty sure that we could create a subview on top of a UITableView. But it seems that it is impossible to do so for UICollectionView?

2nd Edit:

Another screenshot, the arrange buttons are disabled.

enter image description here

3rd edit:

Eventually, I decided to do all these in code and everything works fine (>_<). If anybody know how to solve the issue with the interface builder, I will still very much appreciate it.

UIView *view = [[UIView alloc] initWithFrame:self.view.frame];
view.backgroundColor = [UIColor grayColor];
[self.view addSubview:view];
[self.view bringSubviewToFront:view];

Upvotes: 0

Views: 1461

Answers (1)

Ross Barbish
Ross Barbish

Reputation: 679

You want to move the "View" aka "Progress View" outside of the collection view and below the photo browser in that hierarchy, which would cause it to be the front-most element in the view. The lower something is, the more forward it is.

You can then also use autolayout ("Editor" -> "Align/Pin/Arrange/etc") to reposition or center your progress view.

Upvotes: 1

Related Questions