Subviews

Use this tag for questions related to extracting/manipulating/removing subviews

Uiview

UIView is a class in the UIKit framework of iOS defines a rectangular area on the screen and the interfaces for managing the content in that area

Bigger layer smaller

Example

"The problem was that i was trying to add the bigger layer as a sublayer of the uiscrollview directly instead wrapping the bigger layer in a uiview and adding the bigger layer as a subviews worked"

from question  

UIScrollView inside a CALayer

"Because the uiview is smaller the uiview is going to crop out the larger subviews"

from question  

Is it possible to add uiview with big frame into uiview with small frame

Background size color

Example

"I think your problem is the size of the very root uiview the superview of the uiview you talk about of your views;when a certain subviews is larger than a certain subviews superview a certain subviews will not receive touch events in this portions of a certain subviews s frame that go outside of the superview frame"

from question  

UIView not detecting touch when scaled

"If you want to add several views and change the background color of you header consider adding uiview that fills header view thanks to autolayout constraints and then all the subviews you would like to have to header view i am calling it customcontentview"

from question  

Auto Layout on UITableView header

"On that add a uiview as a subviews with a white background and arrange the size so that a uiview becomes a smaller rectangle inside your cell so a uiview gets this margin effect"

from question  

How can I achieve UITableViewCell margins like this (pic)?

Screen new taller

Example

"When using embed in - uiview the new view will be a bit bigger than the subviews"

from question  

UIView border with fade or blur effect

"Of course uiscrollview can have more than one content view just as any uiview can have more than one subviews and this case it will be more difficult to render its layer"

from question  

I want to generate a image of UIScrollView?

"The uiview is taller than the screen so in ib i pulled it out of the scroll view so i could see it all but i never moved it back to being a subviews of the scroll view"

from question  

Dequeuing UICollectionViewCell while debugging crashes app

"I want to add a uiview of smaller frame as subviews to parental view but i am not getting the needed"

from question  

How to add uiview as a subview to existing view

"Do i just create a new uiview that is 4px larger than the selected object and and make the selected view a subviews of it"

from question  

IPhone SDK, selection Rectangle around a view

"You should be doing it as a uiview not a uiviewcontroller;the general rule in ios development is that view controllers take up the entire screen and views are used for subviews that take up part of the screen though this is less the case for ipad"

from question  

Add a floating bar to a scroll view like in the Facebook iOS app's timeline

"Another way i came up with this to try to work is to create a uiview that spans larger than the scrollview to allow the child view to be a subviews of this larger view that has the scroll view as its parent"

from question  

Programmatic UIScrollview with Autolayout

Others

Example

You are seeing a noticeable jump in interface response because subviews do in fact consume quite a bit of memory uiview are very expensive compared to their underlying calayers and as such calling -removesubview not only unloads stress from the gpu but also frees up more memory as the subviews is usually released afterwards

from question  

Why remove subview?

This can be done for any uiview subclass not just uibuttons;looping through a uiview s subviews is an unreliable way to find a button

from question  

I just had added UIButton to UIView. How can I get buttons index?

Change the contentsize of your scrollview.your uiview size and uiscrollview size is same if the uiscrollview contentsize is more than its subviews size then scroll will happen change the line overviewscroll setcontentsize cgsizemake screenframe.size.width screenframe.size.height-25

from question  

How to work through UIScrollView?

The subviews version is definitely faster since having the controls loose on the uiview took more like 2 seconds to update

from question  

Slow view with Autolayout enabled - lightning fast without

The problem here is that the uiview doesn t own its uiviewcontroller;in the first block of code you held the uiview around by adding it to a subviews but let the uiviewcontroller go away

from question  

EXC_BAD_ACCESS at removeFromSuperview - using ARC

Though earlier uiview and uiscrollview have the same area after keyboard shown the blue uiview becomes smaller but its subviews button text fields is outside its area

from question  

Ios ipad uibutton irresponsive after keyboard show

Either a xib interface builder view or a class that inherits from uiview are equivalent to a user control;they are ways to aggregate sub views think views and subviews - not controls

from question  

.Net UserControl XCode equivalent

I had subclassed uiview added it inside uiscrollview and the gesture recognizers of my subclassed uiview s subviews were not firing - except for the ones that were initially visible as before any scrolling;the simple fix was to add the uiview s subviews directly to the uiscrollview instead of my subclassed uiview

from question  

UIScrollView when contentOffset not at origin, not triggering UIGestureRecognizers attached to subviews

The issue is that once the alpha of the uiview is less than 1.0 i can see all the subviews sides and the one that gets me the most is the outline of an uiimageview can be seen that would otherwise not as it is the same colour as the uiview

from question  

Issue with a scrolling fading UIView and its subviews. How should I be doing it?

The calayer and its sublayers if any is a representation of a uiview but not its subviews;each subviews has its own calayer

from question  

What's the hierarchical relationship with UIView's root layer and root view?

I realize that this may not be possible in all cases but the regular uiview is much easier to customize to the app s appearance than the toolbar and navigation bar where apple has control of the button positioning;instead of setting we custom button as the custom view of the ui bar button object it was we set it as a subviews of the blank ui buttons in the custom view

from question  

IOS 11 UINavigationBar bar button items alignment

You can check the sample working project to add subviews link required code class object to be added as subviews add in parentview as subviews where - firstcontainer is the parent view in which subviews is to be added viewcontroller class object whose view is to be added as subviews note- this can be used in containerviews as well as normal uiview too for adding a controller as subviews

from question  

ViewController.view not getting added to custom view inside Parent View Controller

So if you know what you re doing or are very willing to learn i would strongly suggest not having any fear of creating your own stuff like a custom tab bar which for your purposes is probably nothing more than a uiview with either uibutton subviews or other uiview subviews with tap gesture recognizers attached to them

from question  

Custom Tab Bar iOS

Back to Home
Data comes from Stack Exchange with CC-BY-SA-4.0