【问题标题】:setAlpha in UINavigationControllerUINavigationController 中的 setAlpha
【发布时间】:2010-08-31 18:21:40
【问题描述】:

我想在我的 UINavigationController 中设置 titleView 的 alpha。这是这个类的代码:

#import "FAQNavigationController.h"


@implementation FAQNavigationController

/*
 // The designated initializer.  Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    if ((self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])) {

    }
    return self;
}
*/


// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {

 self.navigationItem.titleView.alpha = 0.5;


    [super viewDidLoad];
}


/*
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
*/

- (void)didReceiveMemoryWarning {
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];

    // Release any cached data, images, etc that aren't in use.
}

- (void)viewDidUnload {
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}


- (void)dealloc {
    [super dealloc];
}


@end

此外,这是该结果的屏幕截图:如您所见,alpha 没有改变。

有什么想法吗?我是不是放错地方了?

【问题讨论】:

标签: objective-c uinavigationcontroller alpha


【解决方案1】:

问题是self.navigationItem.titleView 没有给你任何东西。您可以设置该属性以替换屏幕截图中显示的默认标签。但是,没有任何 API 可以满足您的需求。

问题是:你想达到什么目标?如果需要,您可以使条形图半透明,或更改其色调。更改文本的不透明度并不容易。您可以摆弄控制器的 UINavigationBar 的子视图,但我会避免这样做。

【讨论】:

  • 感谢您的回答,我实际上需要更改实际标题标签的不透明度。您对我如何做到这一点有任何想法吗?我想让设计师开心:)
  • 别让他开心,告诉他太难了。我在这里发布了更详细的讨论和您的其他问题的可能解决方案:stackoverflow.com/questions/3610826/…
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-05-21
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多