江苏福彩快三UI03_UIViewController视图调整器,美术

作者:江苏福彩快三计算机网络

iOS 制作一个归纳的画板,ios制作画板

制作简便画板

  作为iOS初读书人,在念书完UI的多少个轻易控件(UILable,UITextField,UIButton卡塔 尔(阿拉伯语:قطر‎之后,就足以制作二个粗略的画图板demo,以下是维妙维肖制作流程(在MRC下卡塔尔国,如有白玉微瑕,还请各位大神们指教 0.0。

1.搭建分界面,首要由UIButton,UITextField组成,尾部的按键是UITextField的二个自定义键盘(inputView卡塔 尔(阿拉伯语:قطر‎

江苏福彩快三 1

- (void)viewDidLoad {

    [super viewDidLoad];

    //成立菜单按键

    UIButton *menuButton = [UIButton buttonWithType:UIButtonTypeSystem];

    menuButton.frame = CGRectMake(CGRectGetWidth(self.view.bounds) - 80, 40, 60, 40);

    [menuButton setTitle:@"菜单" forState:UIControlStateNormal];

    [menuButton addTarget:self action:@selector(handleMenuButtonAction:) forControlEvents:UIControlEventTouchUpInside];

    [self.view addSubview:menuButton];

 

    //增添textField,但是不想让她显示出来,所以frame = CGRectZero

    UITextField *textField = [[UITextField alloc]initWithFrame:CGRectZero];

    textField.tag = 123;

    [self.view addSubview:textField];

    [textField release];

 

    UIView *inputView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, CGRectGetWidth(self.view.bounds), 60)];

    inputView.backgroundColor = [UIColor whiteColor];

    textField.inputView = inputView;

    [inputView release];

    

    NSArray *titles = @[@"减小",@"增大",@"撤销",@"清空",@"颜色"];

    CGFloat width = (CGRectGetWidth(self.view.bounds) - 20 * 6) / 5;

    CGFloat height = width;

    CGFloat originY = (60 - height) / 2;

    CGFloat originX = 20;

    for (int i = 0 ; i < titles.count; i ) {

        UIButton *button  =  [UIButton buttonWithType:UIButtonTypeSystem];

        button.tag = 100 i;

        button.frame = CGRectMake(originX (width originX) * i , originY, width, height);

        

        [button setTitle:titles[i] forState:UIControlStateNormal];

        button.backgroundColor = [UIColor colorWithRed:arc4random()%6/255.0 green:arc4random()%6/255.0  blue:arc4random()%6/255.0  alpha:0.6]; 

        //将题目标颜料改成米黄。

        [button setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];

        //设置按键的角半径,为开关宽带的百分之五十

         button.layer.cornerRadius = width / 4.0;

        button.layer.masksToBounds = YES;//按钦点的半径收缩视图。

        [button addTarget:self action:@selector(handleButtonAction:) forControlEvents:UIControlEventTouchUpInside];

        [inputView addSubview:button];

    }  

}

 // 以下是菜单按键的响应措施。

- (void)handleMenuButtonAction:(UIButton *)sender{

    //获取textField

    UITextField *textField = (UITextField *)[self.view viewWithTag:123];

    

    //判定倘使textField当前是首先响应者,则裁撤其首先响应者权限,不然让其成为第风流倜傥响应者。

    if (textField.isFirstResponder) {

        [textField resignFirstResponder];

    }else{

        

        [textField becomeFirstResponder];//成为第大器晚成响应者。

    }

}

 

2.创立二个持续NSObject的类LineModel,用于记录线条。

#import <Foundation/Foundation.h>

#import <UIKit/UIKit.h>

//用于记录线条的安慕希素(轨迹path 颜色color 宽度width)

@interface LineModel : NSObject

@property (nonatomic, retain) UIBezierPath *path;//使用贝塞尔曲线纪录触摸轨迹。

@property (nonatomic, retain) UIColor *color;//线条颜色

@property (nonatomic, assign) CGFloat width;//线条宽度 

@end

 

#import "LineModel.h"

 

@implementation LineModel

-(void)dealloc{

    [_color release];

    [_path release];

    [super dealloc];

}

@end

 

3.创设一个世袭UI View的子类PaintView,将上边包车型地铁LineModel,具体落到实处画图板。

@interface PaintView : UIView

@property (nonatomic, retain) NSMutableArray *allLines;//用于保存画板上的富有线条对象。

@property (nonatomic, retain) UIColor *lineColor;//当前的线条颜色。

@property (nonatomic, assign) CGFloat lineWidth;//当前线条的宽

- (void)undoLastDrawing;//打消上次绘制

- (void)allClean;//清空画板。

@end

 

#import "PaintView.h"

#import "LineModel.h"

@implementation PaintView

-(void)dealloc{

    [_allLines release];

    [_lineColor release];

    [super dealloc];

}

-(NSMutableArray *)allLines{

    if (!_allLines) {

        self.allLines = [NSMutableArray array];

    }

    return _allLines;

}

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{

    UITouch *aTouch = touches.anyObject;

    CGPoint startPoint = [aTouch locationInView:self.superview];

    //创造贝塞尔曲线对象,并安装曲线的起头点。

    UIBezierPath *bezierPath = [UIBezierPath bezierPath];

    //设置伊始点。

    [bezierPath moveToPoint:startPoint];

    //创立线条模型对象,并保留当前线条的多个数据

    LineModel *line = [[[LineModel alloc]init]autorelease];

    line.path = bezierPath;

    line.color = self.lineColor;

    line.width = self.lineWidth;

    //增多到数组中等待使用

    [self.allLines addObject:line];

   }

 - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event{

    UITouch *aTouch = touches.anyObject;

    CGPoint cuttentPoint  = [aTouch locationInView:self.superview];

    //获取相应的线条模型(在触摸移动的历程中,数组的末段多个目的对应该前正在绘制的曲线卡塔尔国

    LineModel *aLine = self.allLines.lastObject;

    //在触摸轨迹上增多点。

    [aLine.path addLineToPoint:cuttentPoint];

    [self setNeedsDisplay];//调用此措施是通报视图,绘制分界面,风姿洒脱旦调用此方式,系统就能够自行调用drawRect:方法来绘制分界面。

    }

- (void)drawRect:(CGRect)rect{

        for (LineModel *aLine  in  self.allLines) {

        //设置填充颜色

        [aLine.color setStroke];

        //设置绘制时的线条宽度

        [aLine.path setLineWidth:aLine.width];

        //开端绘制曲线

        [aLine.path stroke];

    }

}

- (void)undoLastDrawing{

    [self.allLines removeLastObject];

    [self setNeedsDisplay];//移除数组中的最后一条曲线对象,一碗水端平绘分界面。

}

- (void)allClean{

    [self.allLines removeAllObjects];

    [self setNeedsDisplay];//消灭全数曲线。

}

@end

4.将PaintView引进视图调控器中,完毕按键的艺术调用。

   ///重写loadView将PaintView作为视图调节器的视图

 

- (void)loadView{

 

    PaintView *paintView  = [[PaintView alloc]initWithFrame:[[UIScreen mainScreen]bounds]];

 

    paintView.backgroundColor = [UIColor whiteColor];

 

    self.view = paintView;

 

    //设置默许的升幅和颜料。

 

    paintView.lineWidth = 10;

 

    paintView.lineColor = [UIColor blackColor];

 

    [paintView release];

 

}

 ////每种按键的贯彻况势。

 

 

- (void)handleButtonAction:(UIButton *)sender{

 

    PaintView *paintView = (PaintView *)self.view;

 

    switch (sender.tag) {

 

        case 100:

 

            if (paintView.lineWidth > 2) {

 

                paintView.lineWidth -= 1;

 

            }

 

            break;

 

        case 101:{

 

            paintView.lineWidth = 1;

 

            break;

 

        }

 

        case 102:{

 

            [paintView undoLastDrawing];

 

            break;

 

        }

 

        case 103:{

 

            [paintView allClean];

 

            break;

 

        }

 

        case 104:{

 

            sender.backgroundColor = [UIColor colorWithRed:arc4random() % 256 / 255.0 green:arc4random() % 256 / 255.0  blue:arc4random() % 256 / 255.0  alpha:1];

 

            //设置画笔颜料

 

            paintView.lineColor = sender.backgroundColor;

 

            break;

 

        }        

 

        default:

 

            break;

 

    }    

 

}

 

 

   那样一个粗略的涂鸦版就制作成了,里面料定还会有大多白璧微瑕,小博第叁遍写博,刚接触资历不足,还请各位给点提出,笔者会继续修改。多谢。

制作一个简易的画板,ios制作画板 制作轻巧画板 作为iOS初读书人,在上学完UI的多少个简易控件(UILable,UITextField,UIButton卡塔 尔(英语:State of Qatar)之后,就足以制...

iOS UI03_UIViewController视图调控器

//

// AppDelegate.m

// UI03_UIViewController视图调控器

//

// Created by dllo on 15/7/31.

// Copyright (c) 2015年 zhozhicheng. All rights reserved.

//

 

#import AppDelegate.h

#import RootViewController.h

@interface AppDelegate ()

 

@end

 

@implementation AppDelegate

-(void)dealloc

{

[_window release];

[super dealloc];

}

 

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];

// Override point for customization after application launch.

self.window.backgroundColor = [UIColor whiteColor];

[self.window makeKeyAndVisible];

[_window release];

//1.创立一个rootViewController对象

RootViewController *rootVC=[[RootViewController alloc] init];

//2.给window设置根视图调节器

self.window.rootViewController=rootVC;

[rootVC release];

 

return YES;

}

 

- (void)applicationWillResignActive:(UIApplication *)application {

// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.

// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.

}

 

- (void)applicationDidEnterBackground:(UIApplication *)application {

// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.

// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.

}

 

- (void)applicationWillEnterForeground:(UIApplication *)application {

// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.

}

 

- (void)applicationDidBecomeActive:(UIApplication *)application {

// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.

}

 

- (void)applicationWillTerminate:(UIApplication *)application {

// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.

}

 

@end

//

// RootViewController.m

// UI03_UIViewController视图调整器

//

// Created by dllo on 15/7/31.

// Copyright (c) 2015年 zhozhicheng. All rights reserved.

//

 

#import RootViewController.h

#define HEIGHT self.view.frame.size.height

//#import LTView.h

#import SecondViewController.h

 

 

@interface RootViewController ()

@property(nonatomic,retain)NSMutableArray *arr;

 

@end

 

@implementation RootViewController

//VC的开头化方法,那几个点子日常本人就调用了,不须求大家再附加的去调用,会最早化一些器皿,比如数组,字典等

-(instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil

{

self =[super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];

if (self) {

self.arr= [NSMutableArray array ];

 

}

NSLog(@%s,__FUNCTION__);

return self;

}

-(void)loadView{

[super loadView];

NSLog(@%s,__FUNCTION__);

//self.view的加载

}

#pragma mark 视图将在现身

-(void)viewWillAppear:(BOOL)animated

{

 

[super viewWillAppear:animated];

NSLog(@%s,__FUNCTION__);

}

#warning 这些是情势已经冒出(本身加的警示)

-(void)viewDidAppear:(BOOL)animated

{

 

[super viewDidAppear:animated];

NSLog(@%s,__FUNCTION__);

}

#pragma mark 视图将在消失

-(void)viewWillDisappear:(BOOL)animated

{

[super viewWillDisappear:animated];

NSLog(@%s,__FUNCTION__);

}

#pragma mark 视图已经没有

-(void)viewDidDisappear:(BOOL)animated

{

[super viewDidAppear:animated];

NSLog(@%s,__FUNCTION__);

}

#pragma mark 如若想要写父类的方法,首先用super去调用父类的法子,那样能够保障原效劳不改变,然后在点子里在写新加上的机能

 

 

 

 

 

- (void)viewDidLoad {

[super viewDidLoad];

// Do any additional setup after loading the view.

self.view.backgroundColor=[UIColor cyanColor];

// NSLog(@%s,__FUNCTION__);

//视图的成立和铺设都在viewdidload方法里开展

//铺三个textfield

UITextField *textField1=[[UITextField alloc] initWithFrame:CGRectMake(100, 200, 150, 40)];

textField1.layer.borderWidth=1;

textField1.layer.cornerRadius=10;

[self.view addSubview:textField1];

textField1.delegate=self;

[textField1 release];

 

UITextField *textField2=[[UITextField alloc] initWithFrame:CGRectMake(100, 300, 150, 40)];

textField2.layer.borderWidth=1;

textField2.layer.cornerRadius=10;

[self.view addSubview:textField2];

textField2.delegate=self;

[textField2 release];

 

UITextField *textField3=[[UITextField alloc] initWithFrame:CGRectMake(100, 400, 150, 40)];

textField3.layer.borderWidth=1;

textField3.layer.cornerRadius=10;

[self.view addSubview:textField3];

textField3.delegate=self;

[textField3 release];

 

 

//铺一个button

UIButton *button=[UIButton buttonWithType:UIButtonTypeSystem];

button.frame=CGRectMake(100, 500, 150, 40);

[button setTitle:@下一页 forState:UIControlStateNormal];

[self.view addSubview:button];

[button addTarget:self action:@selector(click:) forControlEvents:UIControlEventTouchUpInside];

button.layer.borderWidth=1;

button.layer.cornerRadius=10;

 

 

 

 

}

//页面上移

-(BOOL)textFieldShouldBeginEditing:(UITextField *)textField

{

//整个是在self.view,父视图的运动会让全数子视图一齐移动,况且相对父视图坐标地点不会发出转移,所以,可以沿用上三个措施的剖断

//只要输入框被激活,就能够触发这种艺术

if (textField.frame.origin.y > HEIGHT / 2) {

//先做一个差值

CGFloat height =textField.frame.origin.y- HEIGHT / 2;

self.view.center=CGPointMake(self.view.center.x, self.view.center.y - height);

}

return YES;

}

// 等到编写翻译结束的时候,再让他归来原来之处

-(BOOL)textFieldShouldEndEditing:(UITextField *)textField

{

if (textField.frame.origin.y > HEIGHT / 2) {

CGFloat height =textField.frame.origin.y- HEIGHT / 2;

self.view.center=CGPointMake(self.view.center.x, self.view.center.y height);

}

return YES;

}

 

 

 

 

-(void)click:(UIButton *)button

{

//创建三个secondViewController的目的

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

//设置一下跳转的动漫效果

[secondVC setModalTransitionStyle:UIModalTransitionStyleCoverVertical];

//举办跳转

[self presentViewController:secondVC animated:YES completion:^{

 

}];

//内部存款和储蓄器处理

[secondVC release];

 

//差生随时颜色

// [UIColor clearColor];

// self.view.backgroundColor =[UIColor colorWithRed:arc4random() % 256 / 255.0 green:arc4random() % 256 / 255.0 blue:arc4random() % 256 / 255.0 alpha:1 ];

}

 

- (void)didReceiveMemoryWarning {

[super didReceiveMemoryWarning];

// Dispose of any resources that can be recreated.

}

//回笼键盘

-(BOOL)textFieldShouldReturn:(UITextField *)textField

{

[textField resignFirstResponder];

return YES;

}

 

 

 

/*

#pragma mark - Navigation

 

// In a storyboard-based application, you will often want to do a little preparation before navigation

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {

// Get the new view controller using [segue destinationViewController].

// Pass the selected object to the new view controller.

}

*/

 

@end

//

// SecondViewController.m

// UI03_UIViewController视图调控器

//

// Created by dllo on 15/7/31.

// Copyright (c) 2015年 zhozhicheng. All rights reserved.

//

 

#import SecondViewController.h

 

 

@interface SecondViewController ()

 

@end

 

@implementation SecondViewController

 

- (void)viewDidLoad {

[super viewDidLoad];

// Do any additional setup after loading the view.

self.view.backgroundColor=[UIColor whiteColor];

 

 

UIButton *button =[UIButton buttonWithType:UIButtonTypeSystem];

button.frame=CGRectMake(100, 100, 100, 30);

button.layer.borderWidth=1;

button.layer.cornerRadius=10;

[self.view addSubview:button];

[button setTitle:@返回 forState:UIControlStateNormal];

[button addTarget:self action:@selector(click:) forControlEvents:UIControlEventTouchUpInside];

 

 

 

 

 

 

 

 

}

//点击回到前叁个页面

-(void)click:(UIButton *)button

{

[self dismissViewControllerAnimated:YES completion:^{

 

}];

}

 

 

 

 

 

- (void)didReceiveMemoryWarning {

[super didReceiveMemoryWarning];

// Dispose of any resources that can be recreated.

}

 

/*

#pragma mark - Navigation

 

// In a storyboard-based application, you will often want to do a little preparation before navigation

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {

// Get the new view controller using [segue destinationViewController].

// Pass the selected object to the new view controller.

}

*/

 

@end

 

UI03_UIViewController视图调整器 // // AppDelegate.m // UI03_UIViewController视图调整器 // // Created by dllo on 15/7/31. // Copyright (c) 二〇一六年 zhozhicheng. All rig...

摄影板,美术板什么品牌好

知识点:将View上的新闻保存到相册

有关绘制图形、路径

江苏福彩快三 2

******************************************

#import <UIKit/UIKit.h>

@interface FFFPaintView : UIView

@property (nonatomic,strong) UIColor *lineColor;

@property(nonatomic,assign) CGFloat lineWithed;

@property (nonatomic,copy) CGFloat (^lineWithBlock)();

//清屏

-(void)clearScreen;

//回退

-(void)recede;

//橡皮擦

-(void)eraser;

@end

******************************************

#import "FFFPaintView.h"

@interface FFFBezierPath : UIBezierPath

@property (nonatomic,strong) UIColor *lineColor;

@end

@implementation FFFBezierPath

@end

 

@interface FFFPaintView ()

@property (nonatomic,strong) NSMutableArray *paths;

@end

@implementation FFFPaintView

 

-(NSMutableArray *)paths{

 

    if(_paths==nil){

    

        _paths = [NSMutableArray array];

    }

    return _paths;

}

//清屏

-(void)clearScreen{

    

//    注意这里有的时候候移除全体的时候会出错,所以为了幸免,提出 == nil,就能够,然后在重绘

    [self.paths removeAllObjects];

    self.paths = nil;

    //    重绘

    [self setNeedsDisplay];

}

//回退

-(void)recede{

    [self.paths removeLastObject];

    //    重绘

    [self setNeedsDisplay];

}

//橡皮擦

-(void)eraser{

    self.lineColor = self.backgroundColor;

    //    重绘

    [self setNeedsDisplay];

}

 

-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{

//   获取触摸的指标

    UITouch *touch = [touches anyObject];

//    通过触摸对象获得手指的职分

    CGPoint point = [touch locationInView:touch.view];  

//    创制路线对象

    FFFBezierPath *path = [[FFFBezierPath alloc] init];

    [path moveToPoint:point];   

//    设置线的水彩

    path.lineColor = self.lineColor;

 

    if(self.lineWithBlock){

        path.lineWidth = self.lineWithBlock();

    }

//    下边包车型客车艺术是心余力绌得到到值的

//    path.lineWidth = self.lineWithed;

//    NSLog(@"%f",self.lineWithed);

    

//    把path加多到数组中

    [self.paths addObject:path];

}

 

-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event{

 

//    获取触摸的指标

    UITouch *touch = [touches anyObject];

    CGPoint point = [touch locationInView:touch.view];

    

//    使用数组当中最终一个路径 来连线

    [[self.paths lastObject] addLineToPoint:point];

    

//    重绘

    [self setNeedsDisplay];

}

 

-(void)drawRect:(CGRect)rect{

//    遍历全部的路线渲染

    for (FFFBezierPath *path in self.paths) {

        [path.lineColor set];

        

//        设置样式

        [path setLineCapStyle:kCGLineCapRound];

        [path setLineJoinStyle:kCGLineJoinRound];

    //    渲染

        [path stroke];

//        NSLog(@"%@",path);

    }

}

 

@end

 

************************************************************************************

 

#import "ViewController.h"

#import "FFFPaintView.h"

@interface ViewController ()

 

@property (weak, nonatomic) IBOutlet FFFPaintView *paintView;

 

@property (weak, nonatomic) IBOutlet UISlider *slider;

 

@property (weak, nonatomic) IBOutlet UIButton *firstButton;

 

@end

 

@implementation ViewController

//- (IBAction)slider:(UISlider *)sender {

//    

//    self.paintView.lineWithed = sender.value;

//    

//}

 

- (IBAction)savePaint {

    

//    开启图片类型的上下文

    UIGraphicsBeginImageContextWithOptions(self.paintView.bounds.size, NO, 0);

    

//    获取当前上下文

    CGContextRef ctx = UIGraphicsGetCurrentContext();

    

//    把当下view的体制,绘制到上下文此中

    [self.paintView.layer renderInContext:ctx];

    

//    保存到相册,同一时间从上下文中获取图片

    UIImageWriteToSavedPhotosAlbum(UIGraphicsGetImageFromCurrentImageContext(), nil, nil, nil);

    

//    关闭上下文

    UIGraphicsEndImageContext();

}

 

//清屏

-(IBAction)clearScreen{

    [self.paintView clearScreen];

}

//回退

-(IBAction)recede{

    [self.paintView recede];

}

//橡皮擦

-(IBAction)eraser{

    [self.paintView eraser];

}

 

- (void)viewDidLoad {

    [super viewDidLoad];

    [self.paintView setLineWithBlock:^CGFloat{

        return self.slider.value;

    }];

    self.paintView.lineColor = self.firstButton.backgroundColor;

}

 

- (IBAction)setColorSelected:(UIButton *)sender {

    self.paintView.lineColor = sender.backgroundColor;

}

@end

 

 

************************************************************************************

 

 

 

************************************************************************************

 

知识点:将 V iew 上的新闻保存到相册 关于绘制图形、路径 ****************************************** #import UIKit/UIKit.h...

iOS开发_iphone开发_iphone分界面怎么样兑现下拉列表
代码如下:
    
    #import <UIKit/UIKit.h>
    @interface DropDownList : UIView<UITableViewDelegate,UITableViewDataSource> {
    UITextField* textField;   //文本输入框
    NSArray* list;            //下拉列表数据
    BOOL showList;             //是或不是弹出下拉列表
    UITableView* listView;    //下拉列表
    CGRect oldFrame,newFrame;   //整个控件(满含下拉前和下拉后卡塔尔的矩形
    UIColor *lineColor,*listBgColor;//下拉框的边框色、背景象
    CGFloat lineWidth;               //下拉框边框粗细
    UITextBorderStyle borderStyle;   //文本框边框style
    }
    @property (nonatomic,retain)UITextField *textField;
    @property (nonatomic,retain)NSArray* list;
    @property (nonatomic,retain)UITableView* listView;
    @property (nonatomic,retain)UIColor *lineColor,*listBgColor;
    @property (nonatomic,assign)UITextBorderStyle borderStyle;
    -(void)drawView;
    -(void)setShowList:(BOOL)b;
    @end
    #import "DropDownList.h"
    @implementation DropDownList
    @synthesize textField,list,listView,lineColor,listBgColor,borderStyle;
    - (id)initWithFrame:(CGRect)frame {
    
    if(self=[super initWithFrame:frame]){
    //暗中同意的下拉列表中的数据
    list=[[NSArray alloc]initWithObjects:@"1",@"2",@"3",@"4",nil];
    
    borderStyle=UITextBorderStyleRoundedRect;
    
    showList=NO; //私下认可不显得下拉框
    oldFrame=frame; //未下拉时间调整件发轫大小
    //当下拉框呈现时,计算出控件的深浅。
    newFrame=CGRectMake(frame.origin.x, frame.origin.y, frame.size.width, frame.size.height*5);
    
    lineColor=[UIColor lightGrayColor];//默许列表边框线为棕色
    listBgColor=[UIColor whiteColor];//默许列表框背景象为浅灰
    lineWidth=1;     //默许列表边框粗细为1
    
    //把背景象设置为透明色,不然会有八个乌紫的边
    self.backgroundColor=[UIColor clearColor];
    [self drawView];//调用方法,绘制控件
    
    }
    returnself;
    }
    -(void)drawView{
    //文本框
    textField=[[UITextField alloc]
      initWithFrame:CGRectMake(0, 0,
    oldFrame.size.width, 
    oldFrame.size.height)];
    textField.borderStyle=borderStyle;//设置文本框的边框风格
    [self addSubview:textField];
        [textField addTarget:self action:@selector(dropdown) forControlEvents:UIControlEventAllTouchEvents]; 
    
    //下拉列表
    listView=[[UITableView alloc]initWithFrame:
      CGRectMake(lineWidth,oldFrame.size.height lineWidth, 
    oldFrame.size.width-lineWidth*2,
    oldFrame.size.height*4-lineWidth*2)];
    listView.dataSource=self;
    listView.delegate=self;
    listView.backgroundColor=listBgColor;
    listView.separatorColor=lineColor;
    listView.hidden=!showList;//风华正茂开头listView是东躲台湾的,自此基于showList的值展现或规避
    
    [self addSubview:listView]; 
    [listView release];
    }
    -(void)dropdown{
    [textField resignFirstResponder];
    if (showList) {//假使下拉框已显得,什么都不做
    return;
    }else {//如若下拉框还未有展现,则举办展现
    //把dropdownList放到前面,幸免下拉框被其他控件遮住
    
    [self.superview bringSubviewToFront:self];
    [self setShowList:YES];//突显下拉框
    }
    }
    #pragma mark listViewdataSource method and delegate method
    -(NSInteger)tableView:(UITableView *)table numberOfRowsInSection:(NSInteger)section{
    return list.count;
    }
    -(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    static NSString *cellid=@"listviewid";
    UITableViewCell* cell=[tableView dequeueReusableCellWithIdentifier:cellid];
    if(cell==nil){
    cell=[[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault
      reuseIdentifier:cellid]autorelease];
    }
    //文本标签
    cell.textLabel.text=(NSString*)[list objectAtIndex:indexPath.row];
    cell.textLabel.font=textField.font;
    
    cell.selectionStyle=UITableViewCellSelectionStyleGray;
    return cell;
    }
    -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return oldFrame.size.height;
    }
    //当选拔下拉列表中的意气风发行时,设置文本框中的值,掩盖下拉列表
    -(void)tableView:(UITableView *)tableViewdidSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    //NSLog(@"select");
    textField.text=(NSString*)[list objectAtIndex:indexPath.row];
    //NSLog(@"textField.text=%@",textField.text);
    [self setShowList:NO];
    }
    -(BOOL)showList{//setShowList:No为隐藏,setShowList:Yes为显示
    return showList;
    }
    -(void)setShowList:(BOOL)b{
    showList=b;
    NSLog(@"showlist is set ");
    if(showList){
    self.frame=newFrame;
    }else {
    self.frame=oldFrame;
    }
    listView.hidden=!b;
    }
    /*
    
    // Only override drawRect: if you perform custom drawing.
    // An empty implementation adversely affects performance during animation.
    - (void)drawRect:(CGRect)rect {
        // Drawing code.
    }
    */
    - (void)dealloc {
        [super dealloc];
    }
    @end


1.绘图

创设三个进程条View在.h中扬言如下:

#import@interface CircleProgress : UIView

{

CGContextRef ctx;

}

@property (nonatomic, assign) float lineWidth;

@property (nonatomic, strong) UIColor *lineColor;

@property (nonatomic, assign) float startAngle;

@property (nonatomic, assign) float endAngle;

@end


.m实现如下

- (void)drawRect:(CGRect)rect {

// Drawing code

if (_startAngle == 0)

{

_startAngle = 0;

}

if (_endAngle == 0)

{

本文由江苏福彩快三发布,转载请注明来源

关键词: 江苏福彩快三