UIBarButtonItem with custom image and no border

前端 未结 9 677
旧巷少年郎
旧巷少年郎 2020-12-12 12:18

I want to create a UIBarButtonItem with a custom image, but I don\'t want the border that iPhone adds, as my Image has a special border.

It\'s the same as the back b

9条回答
  •  不思量自难忘°
    2020-12-12 13:07

    One another solution, think it's simpler in case when creating button programatically:

    UIBarButtonItem *button = [[UIBarButtonItem alloc] initWithImage:defaultImage
                                                 landscapeImagePhone:landscapeImage
                                                               style:UIBarButtonItemStylePlain
                                                              target:self
                                                              action:@selector(someSelector)];
    [button setBackgroundImage:[UIImage new] forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
    [button setBackgroundImage:[UIImage new] forState:UIControlStateNormal barMetrics:UIBarMetricsLandscapePhone];
    

提交回复
热议问题