how to prevent custom navbar back button image to strech

I have set a custom image to my back button in navigationButton using the following code :

var backButtonImage : UIImage = UIImage(named: "back")!
       // backButtonImage = backButtonImage.resizableImageWithCapInsets(UIEdgeInsets(top: 0,left: 0 ,bottom: 0, right: 0), resizingMode: UIImageResizingMode.RawValue )
        UIBarButtonItem.appearance().setBackButtonBackgroundImage(backButtonImage, forState: .Normal, barMetrics: .Default)

The problem is that It stretches the nav bar button image like this :

How should I stop from auto stretching the image ?



You can do by this way on Objective C, first create a button separately and then add it to the bar button

UIImage *menuImage = [UIImage imageNamed:@"icon-main-normal.png"];
        UIButton *menu = [UIButton buttonWithType:UIButtonTypeCustom];
        menu.bounds =CGRectMake( 0, 0, 30, 30 );
        [menu setImage:menuImage forState:UIControlStateNormal];
        [menu addTarget:self action:@selector(backToHome) forControlEvents:UIControlEventTouchUpInside];
        UIBarButtonItem *menuBtn = [[UIBarButtonItem alloc] initWithCustomView:menu];

        self.navigationItem.leftBarButtonItem = menuBtn;

You can do this on swift by this logic

Need Your Help

Clustered index - multi-part vs single-part index and effects of inserts/deletes

sql sql-server indexing clustered-index

This question is about what happens with the reorganizing of data in a clustered index when an insert is done. I assume that it should be more expensive to do inserts on a table which has a clustered

Appcelerator Titanium and Apple Pay

titanium appcelerator applepay

I am trying to use Apple Pay in a Titanium app. So far I've gotten it to work about a third of the time I run the app, the rest of the time the app crashes. My suspicion is that not adding the appl...