I'm using a custom UINavigationBar which has transparent corners in the upper left and upper right. I'm using [[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:#"navbar.png"] forBarMetrics:UIBarMetricsDefault];
This works great almost all the time but sometimes for instance when I show the keyboard instead of the transparent corners they become white, and when the keyboard slides back the corners go transparent again.
Does anyone have a clue what could cause this? (iOS 6, ARC)
I think I know the cause of it. When I show the keyboard I slide my UITableView up. So I believe it is the UITableViews background that is showing behind the navigation bar. But I would think that the navigation bar wouldn't be affected of that?
Related
I would like it to appear the keyboard is pushing another view up. The problem is there is a UITabbar between the UIView I would like to animate in unison with the keyboard, problem being the UITabbar breaks up what would give that appearance. What I would really like to be able to do is detect when the keyboard is at the exact point my view then animate that view.
Is this possible without going into the private API's?
Too be clear I have the animation working, just working out a way to make it smoother. The effect I am trying to create is similar to the messages app, but there is a UITabbar between to UIView and the bottom of the screen.
Perhaps this will work...
The height of the keyboard on the iPhone is 216 pixels. The default animation duration for the keyboard display is 0.25 seconds.
The height for a tab bar is 44 pixels.
So, if you started the UIView transition animation afterDelay:((44.0/216.0) * 0.25), this should look right on an iPhone. Perhaps try and see?
If this works, it's pretty easy how to figure out for landscape, and iPad, etc.
Additionally, if this does work, in your final implementation, I would avoid hardcoding the 0.25.
I am using a custom color for my UINavigationBars that I set globally (on iOS7) in didFinishLaunchingWithOptions:
[[UINavigationBar appearance] setBarTintColor: [UIColor mainThemeColor]];
This works fine, but in two of my screens I see something very odd. When the view appears, I see a dark glow move in from the right, and the color of the bar ends up to be darker than what I set it to. I tried setting the color in viewDidAppear et al, but the same thing happens.
I have no idea how this can happen, all my views and viewControllers are set up the same.
Also, when the app is in the background, and I go to the app switching view (with all the miniature screens), the bar for those two screens is completely dark, instead of the theme color.
Has anyone seen this?
EDIT: It has to do with calling self.edgesForExtendedLayout = UIRectEdgeNone; on my view controllers. If I remove that line, then the coloring of the navbar remains correct. However, in that case, part of my view is hidden.
In my app I'm tinting the navigation bar to a darker blue color.
The new gradient effects in iOS6 cause the navigation bar to appear much lighter (see below).
If I adjust the color to be darker to compensate for iOS6, it will appear too dark in iOS5.
What's the best way to make them appear the same (or nearly the same)?
Detect the OS version and set different tint colors? Use a background image? Or is there a style setting I can use to change the gradient behavior?
One way you could achieve this is to use a background image and set it using the Appearance proxy introduced in iOS 5.0.
If you create an image that is a thin vertical slice (e.g. width of 1px and height of 44px and the doubled up retina images) and add it to your bundle, then you can then set the navigation bar background image for all navigation bars in your app once using the following method:
[[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:#"navigationBarImage"] forBarMetrics:UIBarMetricsDefault];
If you run that line of code when your app launches, e.g. in the following method of your appDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
Then every navigationBar in your application will look identical. The advantage of using an image like this is that regardless of OS version and any changes that may or may not come in the future, your application will always look the same.
Just be aware the Appearance proxy API was only added in iOS 5.0, so it wont work with older versions of iOS. For a really good overview of the appearance proxy I'd recommend watching the WWDC 2011 video Session 114.
I had this problem as well, and fixed it by taking out the tint color, and instead doing this:
navigationController.navigationBar.barStyle = UIBarStyleBlackTranslucent;
navigationController.navigationBar.backgroundColor = [UIColor blackColor];
Note that this means you'll then have to go change your user interface/xib file, because you changed the style to black translucent - I had to shove everything down 44 points.
Now the navigation bar should look the same in iOS 5 and iOS 6.
First off, how do you test scrolling in the iPad simulator? I have a touch pad and I've tried dragging two fingers and I've tried click & dragging two fingers, but I can't get it to scroll. Am I doing that part correctly?
Assuming that I'm testing properly, why won't my scrollview scroll? I have a basic view controller in my storyboard and I dragged a scrollview into it. I made an outlet from it into my code and then in my code I generate a bunch of buttons and add them to this scrollview. They get displayed properly. Am I missing something?
set scrollview content size such
[MyScrollView setContentSize:CGSizeMake(320, 500)];
this is for iPhone for example.
You can also make two fingers by press the alt key next to cmd in mac
HOLD PRESS alt + mouse move on simulator
set contentsize of the scrollview,to enable scroll.
Detailed explanation
https://developer.apple.com/library/ios/#documentation/WindowsViews/Conceptual/UIScrollView_pg/CreatingBasicScrollViews/CreatingBasicScrollViews.html
You have to define the contentSize of scrollView which is generally bigger in frame than parentview or its frame to make it scrollable.
[viw setContentSize:CGRectMake(width,height)];
set it in viewDidLoad or where You alloc srollview.
I created custom navigation buttons like this:
UIButton * button = [UIButton buttonWithType:UIButtonTypeCustom];
[button setImage:[UIImage imageNamed:#"some.png"] forState:UIControlStateNormal];
....
[[current navigationItem] setLeftBarButtonItem:[[UIBarButtonItem alloc] initWithCustomView:button]];
Where current is UIViewController * type.
All works fine and button created, but it's clickable area outside the button, very close to the middle of the navigation bar. Is it possible to limit clickable area?
I believe thats a "feature" of iOS. THe Navigation Buttons on left and right are smaller than the minimum touch area allowed in iOS. As a result the actual hit zone is much larger than the physical NavigationButton. Including just under the bar, and like you're noticing to the left and right of the button. Its to allow quick touches without having "look" where you're touching. Its one of the key reasons iPhones are more natural to use than most android phones in the early days.
My best guess is that the button is set to center the image and not scale it, so the frame of the button is way too big.
button.frame=CGRectMake(x,y,w,h)
Set the frame to what you want the clickable area to be.
I have initially thought about subclassing the UIBarButtonItem and override -touchInside:.
This does not work though, since UIBarButtonItem is not a subclass of UIView.
What you are trying to achieve is therefore not possible without overriding some private API.