zoukankan      html  css  js  c++  java
  • IOS Custom NavigationItem --写titleView

            //先自己写一个titleView
    	UIView *titleView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 200, 20)];//allocate titleView
    	titleView.backgroundColor=[UIColor blackColor];
    	//Create UILable
    	UILabel	*titleText = [[UILabel alloc] initWithFrame: CGRectMake(100, 0, 50, 20)];//allocate titleText
    	titleText.backgroundColor = [UIColor clearColor];
    	[titleText setText:@"Title"];
    	[titleView addSubview:titleText];
    	[titleText release];//release titleText
    	
    	//Create Round UIButton
    	UIButton *btnNormal = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    	[btnNormal setFrame:CGRectMake(0, 0, 40, 20)];
    	[btnNormal addTarget:self action:nil forControlEvents:UIControlEventTouchUpInside];
    	[btnNormal setTitle:@"Normal" forState:UIControlStateNormal];
    	[btnNormal setFont:[UIFont systemFontOfSize:8]];
    	[titleView addSubview:btnNormal];
    	
    	
    	//Set to titleView
    	 self.navigationItem.titleView = titleView;
    	[titleView release];//release titleView
    	
    	//Custom backgroundImage UIButton
    	UIButton *btnCustom = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    	[btnCustom setFrame:CGRectMake(0, 0, 32, 32)];
    	[btnCustom addTarget:self action:nil forControlEvents:UIControlEventTouchUpInside];
    	[btnCustom setTitle:@"CB" forState:UIControlStateNormal];
    	[btnCustom setBackgroundImage:[UIImage imageNamed:@"whiteButton.png"] forState:UIControlStateNormal];
    	[btnCustom setBackgroundImage:[UIImage imageNamed:@"blueButton.png"] forState:UIControlStateHighlighted];
    	//Create UIBarButtonItem with the customed button
    	UIBarButtonItem *rightBarButton = [[UIBarButtonItem alloc] initWithCustomView:btnCustom];//allocate rightBarButton
    	//Set to rightBarButtonItem
    	self.navigationItem.rightBarButtonItem = rightBarButton;
    	[rightBarButton release];//release rightBarButton
    	
    


  • 相关阅读:
    C# GDI 绘图打印
    使用批处理,WINRAR 创建自解压文件
    c# 开放/封闭原则
    php 盖尔-沙普利算法
    c# 遍历 Mysql 所有表所有列,查找目标数据
    C# 与 C++ 互操作(C# 调用 C++ 的动态链接库)
    c# WPF DataGrid 获取选中单元格信息
    c# WPF SVG 文件的引用(SharpVectors)
    c# 使用网站的身份验证及 Cookie 的获取与使用
    c# HttpListener 使用
  • 原文地址:https://www.cnblogs.com/snake-hand/p/3167803.html
Copyright © 2011-2022 走看看