This question already has answers here:
Replacing UINavigationControllers NavigationBar with UIView
(2 answers)
Closed 7 years ago.
i have a UIImageView .i want to add a trans
inCallBackGroundImgae = [[UIImageView alloc] initWithImage:[UIImage imageNamed:#"caller_texture.png"]];
[inCallBackGroundImgae setFrame:CGRectMake(0,top, self.view.frame.size.width, 250)];
[self.view addSubview: inCallBackGroundImgae];
i want to add a transparent view, where i add a red colour .i don,t want navigation bar i want to add a transparent view
Thanks in advance
Firstly hide navigation bar like this in viewDidLoad method
[self.navigationController.navigationBar setHidden:YES];
Now add your transparent UIView in place of navigationBar
UIView *transparentView = [[UIView alloc] initWithFrame:CGRectMake(0,0, self.view.frame.size.width, 64)];
transparentView.alpha = 0.33f;
[self.view addSubview: transparentView];
EDIT : Adjust your image view frame as transparent view will not be seen.
CGRect imgViewRect = inCallBackGroundImgae.frame;
imgViewRect.origin.y = 64;
imgViewRect.size.height = decrease height here if necessary
inCallBackGroundImgae.frame = imgViewRect;
Please do this one
UIView *transView = [[UIView alloc] initWithFrame:CGRectMake(0,0, self.view.frame.size.width, 50)];// set your height here what ever you wanna.
transView.alpha = 0.5f;// set your alpha how much you wanna transparent.
[inCallBackGroundImgae addSubview: transView];
Related
I am trying to create a view like the below one programmatically but it covers the whole screen and does not be like this. There could be some thing size = Freeform, but could not find code on google to handle this.
UIView *picker = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 260)];
picker.backgroundColor = [UIColor whiteColor];
Actually I want to create this whole view programmatically not though interface Builder.
please help
No other way than CGRectMake
if you want create the UIView that covers the whole screen
UIView *picker = [[UIView alloc] initWithFrame:self.view.bounds];
picker.backgroundColor=[UIColor blueColor];
[self.view addSubview: picker];
if you want create the UIView that not covers the whole screen
UIView *picker = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 250, 260)];
picker.backgroundColor=[UIColor blueColor];
[self.view addSubview: picker];
Create UIToolBar which has UIBarButtonItem(=Done).
Set the UIToolBar as UIDatePicker's inputAccessoryView.
You don't even need a backgroundView to add Done button and date picker.
How come this code is not producing a UINavigationBar on my UIView?
//create the view
UIView *view = [[UIView alloc] init];
view.backgroundColor = [UIColor whiteColor];
//everything for tabbar
UINavigationBar *navBar = [[UINavigationBar alloc] init];
//add the components to the view
[view addSubview: navBar];
//show the view
self.view = view;
I see the white view but no NavBar. Any help? What am I doing wrong?
Set the frame of navigation bar and add it as a subview of the view for it to be seen.Set a frame for any view to be positioned in its super view's coordinate system.
[navBar setFrame:CGRectMake(0,0,CGRectGetWidth(view.frame),44)];
[self.view addSubview:navBar];
Also its a navigation bar, I do not know what tab bar you are willing to see from this code you posted.
I am currently working on an app for iPhone where I have an Imageview showing off some images and via swipe I can change the images.
But I'm currently trying to add a subview that will be a top bar, and when the image is touched, it will make this top bar slide down from the top.
The current code I've tried to do this with is:
CGRect frame = CGRectMake(0.0f, 0.0f, self.view.frame.size.width, 60.0f);
UIView *topBar = [[UIView alloc] initWithFrame:frame];
[self.view addSubview:topBar];
[self.view bringSubviewToFront:topBar];
But the topbar won't show up, and I have logs showing that the touches are recognized.
How do I do this, and how do I properly populate the subview with buttons?
Best Regards.
FreeSirenety
Your topBar has nothing in it, so how can you know it has been added?
CGRect frame = CGRectMake(0.0f, 0.0f, self.view.frame.size.width, 60.0f);
UIView *topBar = [[UIView alloc] initWithFrame:frame];
topBar.backgroundColor = [UIColor redColor];
[self.view addSubview:topBar];
Also you don't need to use the bringSubViewToFront as the view that's gets added as a subview is always the topMost in the view hierarchy!
I'm developing a iOs app for iPad and I'm implementing a UIImageView inside a UIView. The problem is that if the position of the image view has a position out of the UIView that it is inside, you can see it. The code:
UIView *vistafunda = [[UIView alloc] initWithFrame:CGRectMake(512/2, 48, 525, 651)];
[self.view addSubview:vistafunda];
vistafunda.backgroundColor = [UIColor darkGrayColor];
UIImageView *img = [[UIImageView alloc] initWithImage:[UIImage imageNamed:#"hola.png"]];
img.center = CGPointMake(12, 200);
[vistafunda addSubview:img];
I would like that the image view was always under the view, so if the image is outside the view you could not see it.
Thanks!
Just make the containing view clip it's children
vistafunda.clipsToBounds = YES;
Is it possible to embed a CGRect into a navigation bar just like this screenshot: here
I've done this:
UIView *aView = [[UIView alloc]initWithFrame:CGRectMake(10, 10, 10, 10)];
[self.view addSubview:aView];
UILabel *title = [[UILabel alloc] initWithFrame:CGRectMake(100, -15, 150, 10)];
Using a negative figure, it actually allows me to place the label in the same space as the nav bar, but it will be hidden behind it. Is there way for me to bring the label to the front (change the z-index?)? Or is there a way to embed a label in the nav bar?
I've tried using this code but it doesn't effect the label:
[self.view bringSubviewToFront:aView];
Answered thanks to EmptyStack:
Adding this code:
self.navigationItem.titleView = aView;
[aView addSubview:title];
Allows to embed the title (or more) in the navigation bar.
I guess you want this one.
self.navigationItem.titleView = aView;