【代码笔记】关于UIFont的一些define
2016-03-15 10:00
579 查看
一,效果图。
二,工程图。
三,代码。
RootViewController.h
RootViewController.m
Utils.h
Utils.m
二,工程图。
三,代码。
RootViewController.h
#import <UIKit/UIKit.h> @interface RootViewController : UIViewController @end
RootViewController.m
#import "RootViewController.h" #import "Utils.h" @interface RootViewController () @end @implementation RootViewController - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; if (self) { // Custom initialization } return self; } - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view. //初始化背景图 [self addView]; //初始化button [self initButton]; } #pragma -mark -functions //初始化背景图 -(void)addView { self.title=@"UIFont"; } //初始化button -(void)initButton { UIButton *rightButton = [[UIButton alloc] initWithFrame:CGRectMake(50, 100, 100, 50)]; [rightButton setTitleColor:[UIColor grayColor] forState:UIControlStateNormal]; rightButton.backgroundColor=[UIColor redColor]; //给按钮上的字设置大小 [Utils setDefaultFont:rightButton size:20]; [rightButton setTitle:@"完成" forState:UIControlStateNormal]; [self.view addSubview:rightButton]; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. }
Utils.h
#import <Foundation/Foundation.h> @interface Utils : NSObject + (void)setDefaultFont:(id)sender size:(float)size; @end
Utils.m
#import "Utils.h" @implementation Utils //给某个按钮上的数字设置大小 + (void)setDefaultFont:(id)sender size:(float)size{ [sender setFont:[UIFont fontWithName:@"Helvetica" size:size]]; } @end
相关文章推荐
- 【代码笔记】关于UIFont的一些define
- 解决“Dynamic Web Module 3.0 requires Java 1.6 or newer.”错误
- Android仿iOS7的UISegmentedControl 分段
- DJANGO中,用QJUERY的AJAX的json返回中文乱码的解决办法
- 详解iOS App开发中UIViewController的loadView方法使用
- Platform Builder 6.0 180天试用过期
- Java Web后台通过request.getParameter( )方法得到的数据中文乱码
- Bluemix结合DevOps Service实现一键部署
- UITableView
- Is there any way to define a min and max value for edittext in android?
- android基础回顾(三)基础UI组件
- iOS-UIDynamic物理仿真-捕捉-UISnapBehavior
- 同一设置UINavigationBar
- UITextField的键盘(格式化设置)
- Sea.js & Require.js
- iOS-UIDynamic物理仿真-重力、碰撞
- java7新特性之—String values in a switch statement
- 前端开发总结--之关于FusionSphere WEBUI的想法
- juicer js模板引擎
- UIView的layoutSubviews和drawRect方法何时调用