ishan
ishan

Reputation: 301

Use a UIView ( created using xib) multiple times as a subview to the same view

My requirement is that I want to create a view which has to be added to a scrollview multiple times ( 12 times for each month ) with a pagecontrol , loaded with different data.

The requirement specifically is to use a scrollview/pagecontroll with previous/next page visible.

I have successfully done that by manually creating the view, but when i reduce the alpha of the added view, the alpha of all the ui components added to it is reduced.

hence i need to create the view using xib. But view instantiated using xib are getting added to the scrollview only once. remaining pages as just blank.

Any ideas on how to proceed here will be highly appreciated.

Upvotes: 0

Views: 664

Answers (2)

Omar Abdelhafith
Omar Abdelhafith

Reputation: 21221

Go back to creating the view manually, but instead of adding ui controls to it, create another parent view and add your created view and the other ui view as children to this parent view,

Now when u decrease the alpha on the view, other ui controls will not be affected since they will not be children to this view.

So your new view arrangement would be:

Parent View -> your created view (the one that you want to change its alpha)
            -> other ui controls

So your view will not be the parent of other ui controls

Upvotes: 1

Jitendra Singh
Jitendra Singh

Reputation: 2181

You will have to create different instances of same UIView class and add as subview on UIScrollView. And for alpha, the alpha set for parent view will override all its child.

Upvotes: 0

Related Questions