[英]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.