2

I spent a lot of time trying optimize my app for iPhone6/6+, but several UI elements have not yet been obtained to optimize.

  1. UINavigationBar & UISearchBar with custom image background [SOLVED]:

enter image description here

    [[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:@"navBar"]       forBarMetrics:UIBarMetricsDefault];

UISearchBar's background was set in storyboard.

There is ImageSet for UINavigationBar and UISearchBar which contains 1x, 2x, and 3x png files.

  1. UITableViewCell: [SOLVED]

enter image description here

cellForRowAtIndexPath:

cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
        [cell setSelectionStyle:UITableViewCellSelectionStyleNone];
        [cell setBackgroundColor:[UIColor clearColor]];

        UISegmentedControl *mapTypeSelect = [[UISegmentedControl alloc]
                                             initWithItems:
                                             [NSArray arrayWithObjects:
                                                NSLocalizedString(@"MAP_STANDART", nil),
                                                NSLocalizedString(@"MAP_HYBRID", nil),
                                                NSLocalizedString(@"MAP_SATELLITE", nil),
                                                nil]];

        CGSize cF = cell.frame.size;
        [mapTypeSelect setFrame:CGRectMake(10, 5, cF.width-20, cF.height-10)];
  1. UISearchDisplayController position (1 - search activated; 2 - search began):

enter image description here enter image description here

Any help is appreciated!

Thank you

Romowski
  • 1,518
  • 5
  • 25
  • 50
  • 1
    #2: You are setting a frame for the `UISegmentedControl`. An adaptive UI that works for an iPhone 4S, 5/5S, 6 and 6+ will need to use constraints/autolayout. A better method would be a Storyboard cell / xib cell (with constraints) rather than generating the cell in code but you could add the constraints in code if you prefer. – Robotic Cat Nov 19 '14 at 05:19
  • @RoboticCat: Thank you! My inattention - in another class I did exactly as you wrote )) Do you have any solution for #1 and #3? – Romowski Nov 19 '14 at 07:30
  • Absolutely no idea for #1 or #3. Good luck. – Robotic Cat Nov 19 '14 at 11:59

1 Answers1

0

I have found solution for question #1 from iOS 8 NavigationBar BackgroundImage

EDITED after @RoboticCat answer

UIEdgeInsets stretchablePart = { .left = 0, .right = 50, .top = 0, .bottom = 0 };
[[UINavigationBar appearance] setBackgroundImage:[[UIImage imageNamed:@"navBar"] resizableImageWithCapInsets:stretchablePart resizingMode:UIImageResizingModeStretch] forBarMetrics:UIBarMetricsDefault];

where navBar is Imageset of 1x,2x and 3x images

Community
  • 1
  • 1
Romowski
  • 1,518
  • 5
  • 25
  • 50