代码之家  ›  专栏  ›  技术社区  ›  Jesse Bunch

UINavigationController中的setAlpha

  •  0
  • Jesse Bunch  · 技术社区  · 15 年前

    我想在我的UINavigationController中设置标题视图的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没有改变。

    alt text

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

    1 回复  |  直到 15 年前
        1
  •  1
  •   Max Seelemann    15 年前

    问题是 self.navigationItem.titleView

    问题是:你想达到什么目标?你可以使酒吧半透明,如果你想,或改变它的色调。更改文本不透明度不是太容易。你呢 能够