简体   繁体   中英

Create a sticky view to the navigationBar

How can i create a UIView which is sticky to the navigationBar like this image. On this image even though you scroll it will still be there:

在此处输入图片说明

You Can Try This 在此处输入图片说明

 [self.navigationItem setTitle:@"Vijay"];

    UIImage *image = [UIImage imageNamed:@"tabarrrr"];
    [self.navigationController.navigationBar setBackgroundImage:image forBarPosition:UIBarPositionAny barMetrics:UIBarMetricsDefault];
    [self.navigationController.navigationBar setShadowImage:image];
    [self.navigationController.navigationBar setShadowImage:[UIImage new]];
    [self.navigationController setNavigationBarHidden:FALSE];
    [self.navigationController.navigationBar setTintColor:[UIColor whiteColor]];


//    
//    UIBarButtonItem *RigthButtonClicek=[[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"search.png"] style:UIBarButtonItemStylePlain target:self action:@selector(RigthButtonClicek:)];

    UIButton *button1=[UIButton buttonWithType:UIButtonTypeCustom];
    [button1 setFrame:CGRectMake(10.0, 2.0, 40, 20.0)];
    [button1 addTarget:self action:@selector(RigthButtonClicek:) forControlEvents:UIControlEventTouchUpInside];
    [button1 setImage:[UIImage imageNamed:@"cancelbtn.png"] forState:UIControlStateNormal];
    UIBarButtonItem *button = [[UIBarButtonItem alloc]initWithCustomView:button1];
    self.navigationItem.leftBarButtonItem = button;


    UIButton *button2=[UIButton buttonWithType:UIButtonTypeCustom];
    [button2 setFrame:CGRectMake(10.0, 2.0, 40, 20.0)];
    [button2 addTarget:self action:@selector(RigthButtonClicek:) forControlEvents:UIControlEventTouchUpInside];
    [button2 setImage:[UIImage imageNamed:@"search.png"] forState:UIControlStateNormal];
    UIBarButtonItem *button3 = [[UIBarButtonItem alloc]initWithCustomView:button2];
    self.navigationItem.rightBarButtonItem = button3;

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM