navigation自定义title

本文介绍如何使用UILabel并自定义其样式,包括背景颜色、字体大小、阴影颜色、文本对齐方式及文本颜色等属性设置。
 UILabel *label = [[[UILabel alloc] initWithFrame:CGRectZero] autorelease];
        label.backgroundColor = [UIColor clearColor];
        label.font = [UIFont boldSystemFontOfSize:20.0];
        label.shadowColor = [UIColor colorWithWhite:0.0 alpha:0.5];
        label.textAlignment = UITextAlignmentCenter;
        label.textColor = [UIColor yellowColor]; // change this color
        self.navigationItem.titleView = label;
        label.text = NSLocalizedString(@"PageThreeTitle", @"");
        [label sizeToFit];

自定义BottomNavigationView的样式,可以按照以下步骤: 1. 在布局文件中添加BottomNavigationView: ```xml <com.google.android.material.bottomnavigation.BottomNavigationView android:id="@+id/bottom_navigation" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="bottom" app:menu="@menu/bottom_navigation_menu" /> ``` 2. 创建一个menu文件,定义底部导航栏的菜单项: ```xml <?xml version="1.0" encoding="utf-8"?> <menu xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto"> <item android:id="@+id/navigation_home" android:icon="@drawable/ic_home" android:title="@string/home" app:showAsAction="ifRoom" /> <item android:id="@+id/navigation_dashboard" android:icon="@drawable/ic_dashboard" android:title="@string/dashboard" app:showAsAction="ifRoom" /> <item android:id="@+id/navigation_notifications" android:icon="@drawable/ic_notifications" android:title="@string/notifications" app:showAsAction="ifRoom" /> </menu> ``` 3. 在代码中获取BottomNavigationView的实例,然后进行自定义样式的设置: ```java BottomNavigationView bottomNavigationView = findViewById(R.id.bottom_navigation); bottomNavigationView.setItemIconTintList(null); // 取消图标着色 bottomNavigationView.setItemTextColor(ColorStateList.valueOf(Color.parseColor("#000000"))); // 设置文字颜色 bottomNavigationView.setBackgroundColor(Color.parseColor("#FFFFFF")); // 设置背景颜色 ``` 以上就是自定义BottomNavigationView样式的基本步骤,你可以根据需要自行修改样式。
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值