[英]Instagram-like refresh button
我真的试图像Instagram的按钮那样做一个按钮(rightBarButtonItem),我认为不可能同时在按钮上设置背景图像和图像。
看到这个
**
**
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;
这里的图像:
背景图片(2x) http://d.pr/i/BYS9
刷新图像(2x) http://d.pr/i/Hg5u
我正在寻找做instagram应用程序的相同按钮,在背景图像中设置刷新图像。
希望你帮我这个。
不幸的是,UIBarButtonItem不是UIButton的子类,因此不具备UIButton具有的复杂属性和可定制性。 Instagram实现此按钮的方式是只有一个图像是覆盖在背景图像上的刷新图像。 按下按钮时,它们会隐藏物品并用风车将其更换。
或者,您可以创建自定义按钮,将所需属性添加到该按钮,然后使用该按钮创建条形项:
UIBarButton* button initWithCustomView:customButton;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.