ios开发过程中添加新的视图使用UITabBarControl

//

//  HomeViewController.m

//  UsingTabBarController01

//

//  Created by chen neng on 11-9-5.

//  Copyright 2011 ydtf. All rights reserved.

//


#import "HomeViewController.h"



@implementation HomeViewController

-(void)loadView{

[super loadView];

//一个动态数组,用于作为TabViewControllerviewControllers;

NSMutableArray *viewControllerArray = [NSMutableArray array];

//创建第一个视图初始化

UIViewController *firstVC=[[UIViewController alloc]init];

firstVC.view.backgroundColor=[UIColor redColor];

    //初始化第一个界面的下方的按钮的文字和图标房子文字是red

firstVC.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"Red" image:[UIImage imageNamed:@"index.png"] tag:1000];

    //添加进视图数组中

[viewControllerArray addObject:firstVC];

[firstVC release];

UIViewController* secondVC=[[UIViewController alloc]init];

secondVC.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"blue" image:[UIImage imageNamed:@"settings.png"] tag:2000];

secondVC.view.backgroundColor=[UIColor blueColor];

[viewControllerArray addObject:secondVC];

[secondVC release];

    UIViewController* thirdVC=[[UIViewController alloc]init];

thirdVC.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"yellow" image:[UIImage imageNamed:@"settings.png"] tag:2000];

thirdVC.view.backgroundColor=[UIColor yellowColor];

[viewControllerArray addObject:thirdVC];

[thirdVC release];

self.viewControllers = viewControllerArray;

}

@end

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
iOS开发,我们可以通过添加水印来给UIView添加一些额外的视觉效果。下面是一个实现的示例代码: ```swift // 创建带有水印的UIView子类 class WatermarkView: UIView { let watermarkText: String // 水印文本 init(frame: CGRect, watermarkText: String) { self.watermarkText = watermarkText super.init(frame: frame) } required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") } override func draw(_ rect: CGRect) { super.draw(rect) // 设置水印文本的属性 let attributes: [NSAttributedString.Key : Any] = [ .font: UIFont.systemFont(ofSize: 16), .foregroundColor: UIColor.white.withAlphaComponent(0.5) ] // 绘制水印文本 let watermarkString = NSAttributedString(string: watermarkText, attributes: attributes) watermarkString.draw(at: CGPoint(x: 10, y: rect.height - 30)) } } // 在ViewController使用WatermarkView class ViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() // 创建一个带有水印的UIView并添加到当前视图控制器视图层级 let watermarkView = WatermarkView(frame: view.bounds, watermarkText: "Watermark") view.addSubview(watermarkView) } } ``` 在上面的示例代码,我们创建了一个名为`WatermarkView`的UIView子类。在其`draw(_ rect:)`方法,我们使用`NSAttributedString`绘制了带有水印文本的视图。我们可以调整文本的字体和颜色等属性来满足需求。 在ViewController,我们使用`WatermarkView`类创建了一个带有水印的UIView实例,并将其添加到当前视图控制器的视图层级。通过这样的方式,我们可以在应用的任何需要的位置添加水印效果。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值