如何在Uphone的导航栏中添加UILabel UIImageView? [英] How to Add UIImageView with UILabel in navigation bar of iphone?

查看:142
本文介绍了如何在Uphone的导航栏中添加UILabel UIImageView?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的iphone应用程序的 UI 中有一些导航栏。现在我想在导航栏中心的导航栏上添加两个图像..
我已经在导航栏上成功添加了两个 UIImageView 但是我的问题是我有两个带有标签的 UIImageView ..

I have some navigation bar in my UI of iphone app. Now i want to add two images on the navigation bar on center of the navigation bar.. I have successfully added the two UIImageView on the navigation-bar but my problem is that i have two UIImageView with the label on it ..

让我给你看快照.. 。

Let me show u the snapshot ...

现在我的问题是我不知道如何在导航栏中的 UIImageView 附近添加这种标签。如果有人可以指导我,那么它会帮助我很多..

now my problem is i don't know how to add this kind of label near UIImageView in navigation bar..so please if anyone can guide me for this then it will help me a lot..

我已经使用此代码在导航栏上成功插入了两张图片。

i have already successfully inserted two images on navigation bar with this Code.

   UIImageView *Messageview = [[UIImageView alloc] initWithImage:[UIImage imageNamed :"message.png"]];
        Messageview.frame=CGRectMake(10, 0, 40, 40);

        UIImageView *BirthdayView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:"birthday.png"]];
        //titleView.frame=CGRectMake(60, 0, 50, 50);

UIBarButtonItem *flexible = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];

    [flexible setWidth:20];
    UIBarButtonItem *flexible1 = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];

    [flexible setWidth:20];


        UIBarButtonItem *MessageBtn=[[UIBarButtonItem alloc]initWithCustomView:Messageview];

        UIBarButtonItem *BirthdayBtn=[[UIBarButtonItem alloc]initWithCustomView:BirthdayView];
        self.navigationItem.rightBarButtonItems=[NSArray arrayWithObjects:rofileBtn,flexible,BirthdayBtn,MessageBtn,flexible1,nil];

请尽快引导我..

推荐答案

我认为这对你有帮助。

 UIView *msgView=[[UIView alloc]initWithFrame:CGRectMake(10, 0, 40, 40)];
    UIImageView *Messageview =[[UIImageView alloc]initWithImage:[UIImage imageNamed:@"message.png"]];

    Messageview.frame=CGRectMake(0, 0, 20, 20);

    [msgView addSubview:Messageview];

    UILabel *lbl=[[UILabel alloc]initWithFrame:CGRectMake(30, 0, 20, 20)];
    [lbl setText:@"Text"];
    [msgView addSubview:lbl];
UIBarButtonItem *MessageBtn=[[UIBarButtonItem alloc]initWithCustomView:msgView];

这篇关于如何在Uphone的导航栏中添加UILabel UIImageView?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆