Iphone 类似Instagram的刷新按钮

Iphone 类似Instagram的刷新按钮,iphone,ios,objective-c,xcode,navigation,Iphone,Ios,Objective C,Xcode,Navigation,我真的尝试过做一个按钮(RightBarButtonim),就像instagram的按钮一样,我认为不可能同时设置按钮的背景图像和图像 看看这个 ** AppDelegate.m ** FirstViewController.m 以下是图片: 背景图像(2x) 刷新图像(2x) 我想要做的是使用instagram应用程序的相同按钮,在背景图像中设置刷新图像 希望您能在这方面帮助我。不幸的是,uibarbuttonite不是UIButton的子类,因此没有UIButton所具有的复杂属性和可定制

我真的尝试过做一个按钮(RightBarButtonim),就像instagram的按钮一样,我认为不可能同时设置按钮的背景图像和图像

看看这个

**

AppDelegate.m **

FirstViewController.m 以下是图片:

背景图像(2x)

刷新图像(2x)


我想要做的是使用instagram应用程序的相同按钮,在背景图像中设置刷新图像


希望您能在这方面帮助我。

不幸的是,uibarbuttonite不是UIButton的子类,因此没有UIButton所具有的复杂属性和可定制性。Instagram实现此按钮的方式是,只有一个图像是叠加在背景图像上的刷新图像。当按下按钮时,他们会隐藏该项目并将其替换为风车

或者,您可以创建自定义按钮,将所需属性添加到该按钮,然后使用该按钮创建条形图项目:

UIBarButton*按钮初始化WithCustomView:customButton

NSDictionary *faTextAttributes = @{ UITextAttributeFont : [UIFont fontWithName:@"Arial" size: 12],
                                        UITextAttributeTextColor : [UIColor whiteColor],
                                        UITextAttributeTextShadowColor: [UIColor blackColor],
                                        UITextAttributeTextShadowOffset: [NSValue valueWithCGSize: CGSizeMake(0,0)] };


    [[UIBarButtonItem appearanceWhenContainedIn:[UINavigationBar class], nil]
     setTitleTextAttributes:faTextAttributes forState:UIControlStateNormal];
    [[UIBarButtonItem appearanceWhenContainedIn:[UINavigationBar class], nil]
     setTitleTextAttributes:faTextAttributes forState:UIControlStateHighlighted];


    [[UIBarButtonItem appearanceWhenContainedIn:[UINavigationBar class], nil]
     setBackgroundImage:[UIImage imageNamed:@"bar"] forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
    [[UIBarButtonItem appearanceWhenContainedIn:[UINavigationBar class], nil]
     setBackgroundImage:[UIImage imageNamed:@"bar"] forState:UIControlStateHighlighted barMetrics:UIBarMetricsDefault];
UIBarButtonItem *rightButton = [[UIBarButtonItem alloc] initWithTitle:@"" style:UIBarButtonItemStyleDone target:nil action:nil];

self.navigationItem.rightBarButtonItem = rightButton;