Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to position a View as Subview?
    primarykey
    data
    text
    <p>I want to position a view (red box with label and button) prepared in IB as Subview on the screen programmatically. The positioning works fine with the "blue lines" (there might actually be a better way to simply draw a line on a view?!). But the view of the "AttributeApertureView" view object sticks to the top instead of following the initFrame Parameter starting at y=60 as you can see in the screenshot.</p> <pre><code> //Add blue Line CGRect lineB = CGRectMake(0, 48, bounds.size.width, 0.5); UIView *secondLine = [[UIView alloc]initWithFrame:lineB]; [secondLine setBackgroundColor:[UIColor colorWithRed:0.396 green:0.796 blue:0.894 alpha:1]]; [[self view]addSubview:secondLine]; //Add Attribute Aperture AttributeApertureView *aperture = [[AttributeApertureView alloc]initWithFrame:CGRectMake(0, 60, bounds.size.width, 50)]; [aperture setBackgroundColor:[UIColor redColor]]; [[self view]addSubview:aperture]; </code></pre> <p>Init function in AttributeApertureView class. This should basically only load the related nib file with the IB Interface.</p> <pre><code>@implementation AttributeApertureView - (id)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { NSArray *nib = [[NSBundle mainBundle]loadNibNamed:@"AttributeApertureView" owner:self options:nil]; self = [nib objectAtIndex:0]; } return self; } </code></pre> <p><img src="https://i.stack.imgur.com/FuoeF.jpg" alt="enter image description here"></p> <p>What is the best way to position the "aperture" view on the screen?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload