IOS7 UINavigationBar black background - colors

Does anybody know, how I can make the UINavigationBar solid black in IOS7? Default it is white, and I need it black.

If you're targeting only iOS 7 you can use:
[[UINavigationBar appearance] setBarTintColor:(UIColor *)];

Here is one way that creates a black UIImage programmatically and sets it for the UINavigationBar's appearance:
UIView *background = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 568, 44)];
background.backgroundColor = [UIColor blackColor];
UIGraphicsBeginImageContext(background.frame.size);
CGContextRef context = UIGraphicsGetCurrentContext();
[background.layer renderInContext:context];
UIImage *backgroundImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
[[UINavigationBar appearance] setBackgroundImage:backgroundImage
forBarMetrics:UIBarMetricsDefault];

found it by myself. Go into storyboard-designer, select the ViewController, go to attribute inspector and change Top Bar from inferred to 'Opaque black navigation bar'

Related

How to bring up text on image in uipickerview

Before insert image in uipickerview
After insert image in uipickerview
- (UIView *) pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row
forComponent:(NSInteger)component reusingView:(UIView *)view {
CGRect imageFrame = CGRectMake(0.0, 0.5, 255, 250);
UIImageView *label = [[UIImageView alloc]
initWithFrame:imageFrame];
label.backgroundColor=[UIColor scrollViewTexturedBackgroundColor];
[label sendSubviewToBack:pview];
[pview sendSubviewToBack: label];
[pview addSubview:label];
return label;
}
In your code you have written this:-
[label sendSubviewToBack:pview];
[pview sendSubviewToBack: label];
I think you are doing mistake here..
you just use this:-
[label sendSubviewToBack:pview];
[label addSubview:pview];
remove this
[pview sendSubviewToBack: label];
it will work fine..if not feel free to ask..enjoy..

UIImageView autoresize programmatically

I'm trying to align an imageView at the bottom of my UIViewController, but on iPhone 5 simulator it isn't aligned on the bottom.
I've tried to put an imageView at the bottom of the storyboard and it is aligned correctly so I guess I miss something in my code.
Any advice?
Thanks,
e.
imageView=[[UIImageView alloc] initWithFrame:CGRectMake(0, 416, 320, 64)];
[imageView setContentMode:UIViewContentModeScaleToFill];
imageView.autoresizingMask=UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleTopMargin;
[self.view addSubview:imageView];
got it, used
[self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:#"V:[xmlView]|"
options:0
metrics:0 views:NSDictionaryOfVariableBindings(xmlView)]];
Set the Frame Size like this:
UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(self.view.frame.origin.x, self.view.frame.size.height-64, 320, 64)];
[imageView setContentMode:UIViewContentModeScaleToFill];
[self.view addSubview:imageView];
Hope this will help.

UITabBarItem remove background color gray/blue

I wonder if is possible to remove background color on selected Item of a UITabBar
I want to remove gray background of UITabBar button. Is it possible ??
I put selected and normal image on delegate method:
- (void)tabBar:(UITabBar *)theTabBar didSelectItem:(UITabBarItem *)item{
NSUInteger indexOfTab = [[theTabBar items] indexOfObject:item];
[item setFinishedSelectedImage:[UIImage imageNamed:
[NSString stringWithFormat:#"%u_btnH.png",indexOfTab]]
withFinishedUnselectedImage:[UIImage imageNamed:
[NSString stringWithFormat:#"%u_btn.png",indexOfTab]]
];
}
My custom TabBarItem image are 0_btn.png for normal and 0_btnH.png for selected/hover image
Just set the selectionIndicatorImage to an empty image:
[[UITabBar appearance] setSelectionIndicatorImage:[UIImage alloc]];

how can I set contentoffset and change the height of UIScrollview at same time

I'm trying to scroll up my UISCrollView when the keyboard is shown
I use setContentOffset to shift the uiview up.
At the same time I want to decrease the height of my UISCrollView to (view height - keyboard height), so that the entire content view can be scrolled.
I apply both the changes in keyboardWillShow notification
When I actually bring the keyboard up in my app, the contents first get pushed up and then they are pushed down (which gives a flickering effect). I'm trying to smooth out both the transformations in one go..
Is it possible?
Code Below ---
- (void) keyboardWillShow {
CGPoint contentOffset = scrollView.contentOffset;
CGRect scrollViewFrame = scrollView.frame;
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.3];
if (contentOffset.y >= 0 && contentOffset.x >= 0) {
isContentOffset = YES;
contentOffset.y += screenShift;
[scrollView setContentOffset:contentOffset animated: NO];
}
scrollViewFrame.size.height = keyboardOrigin.y - self.view.frame.origin.y - toolbarHeight;
scrollView.frame = scrollViewFrame;
[UIView commitAnimations];
}
There is an option for animation when you setContentOffset for animation. here is the code that i use all the time
- (void)textViewDidBeginEditing:(UITextView *)textView
{
svos = scrollView.contentOffset;
CGRect rect = [textView bounds];
rect = [textView convertRect:rect toView:self.scrollView];
CGPoint point = rect.origin ;
point.x = 0 ;
[self.scrollView setContentOffset:point animated:YES];
doneButton.enabled = YES;
}
- (IBAction)donePressed
{
[scrollView setContentOffset:svos animated:YES];
[textview resignFirstResponder];
doneButton.enabled = NO;
}
It works fine for me.
Are you wrapping these changes in an animation block?
[UIView beginAnimations:#"resizeScroll" context:nil];
// make your changes to set and content offset
[UIView commitAnimations];
I think I have got a solution for this. You can handle the resize of the view in textViewDidBeginEditing method. You can just change the frame size of the scrollView to half by
CGRect tframe = myscrollView.frame;
tframe.size.height/=2;
myscrollView.frame = tframe;
and to initialize or handle the total length of the scrollview you can set the contentSize of the scrollView in the similar fashion as the frame was set in above snippet. for example
CGSize tsize = self.view.frame.size;
//here you can change the height and width of the scrollView
myscrollView.contentSize = tsize;
I hope this should do the trick for you. If it does please communicate.
Figured out the issue...
When the keyboard button was clicked, I was doing a becomeFirstResponder followed by a resignFirstResponder on keyboard view. This caused keyboardWillShow followed by keyboardWillHide and another keyboardWillShow notification, which brought the keyboard up, brought it back down and then up again.
Thanks to everybody who tried to help out.. and sorry the issue was pretty different...

Changing UIWebView default color to UIImage

Is it possible to place an image in the UIWebView background instead of that gray default color. If yes then how?
Did it by myself.
self.webView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageWithContentsOfFile:backgroundImage]];
In your viewDidLoad please Add this code for loading image at startup
[webView setOpaque:NO];
webView.backgroundColor=[UIColor colorWithPatternImage:[UIImage imageNamed:#"night.jpg"]];
self.webView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageWithContentsOfFile:imagePath]];

Resources