//
// ViewController.m
// UIPickerView改变字体大小
//
// Created by dc008 on 15/12/8.
// Copyright © 2015年 CXY. All rights reserved.
//
#import "ViewController.h"
#import "MyView.h"
#import "TestView.h"
@interface ViewController ()<UIPickerViewDelegate,UIPickerViewDataSource>
{
NSArray *array;
NSArray *arrayTwo;
UIPickerView *pickerView;
TestView *_myView;
}
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
pickerView= [[UIPickerView alloc]initWithFrame:CGRectMake(80, 400, 200, 100)];
pickerView.dataSource=self;
pickerView.delegate=self;
[self.view addSubview:pickerView];
array = @[@"十号字体",@"十一号字体",@"十二号字体",@"十三号字体",@"十四号字体",@"十五号字体"];
arrayTwo = @[@"10",@"11",@"12",@"13",@"14",@"15"];
_myView= [[TestView alloc]initWithFrame:CGRectMake(20, 120, 335, 300)];
[self.view addSubview:_myView];
NSLog(@"%@", _myView);
}
- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView{
return 1;
}
- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component{
return array.count;
}
- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component{
return array[row];
}
-(void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component{
_myView.value = [arrayTwo[row] floatValue];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
//
// TestView.h
// UIPickerView改变字体大小
//
// Created by dc008 on 15/12/8.
// Copyright © 2015年 CXY. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface TestView : UIView
@property(nonatomic, assign)float value;
@end
//
// ViewController.m
// UIPickerView改变字体大小
//
// Created by dc008 on 15/12/8.
// Copyright © 2015年 CXY. All rights reserved.
//
#import "ViewController.h"
#import "MyView.h"
#import "TestView.h"
@interface ViewController ()<UIPickerViewDelegate,UIPickerViewDataSource>
{
NSArray *array;
NSArray *arrayTwo;
UIPickerView *pickerView;
TestView *_myView;
}
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
pickerView= [[UIPickerView alloc]initWithFrame:CGRectMake(80, 400, 200, 100)];
pickerView.dataSource=self;
pickerView.delegate=self;
[self.view addSubview:pickerView];
array = @[@"十号字体",@"十一号字体",@"十二号字体",@"十三号字体",@"十四号字体",@"十五号字体"];
arrayTwo = @[@"10",@"11",@"12",@"13",@"14",@"15"];
_myView= [[TestView alloc]initWithFrame:CGRectMake(20, 120, 335, 300)];
[self.view addSubview:_myView];
NSLog(@"%@", _myView);
}
- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView{
return 1;
}
- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component{
return array.count;
}
- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component{
return array[row];
}
-(void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component{
_myView.value = [arrayTwo[row] floatValue];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end