UI开发----UIController及其子类

//  Created By 郭仔    2015年04月17日23:30:33

今天搞了一晚上的设计模式,本来用ios启动流程的初始代理UIApplicationDeleg来设置页面转换的,却越来越麻烦,还是用了简单的笨方法实现了,明天把这个内容写下来。

==================

没什么时间了,直接上代码:

==================

UIImageView:

    // =================UIImageView====================================
    
    UIImageView * imageView = [[UIImageView alloc]initWithFrame:CGRectMake(100, 200, 50, 50)];
    imageView.image = [UIImage imageNamed:@"3"];
    [imageView.layer setShadowColor:[UIColor greenColor].CGColor];
    imageView.layer.shadowOffset = CGSizeMake(5, 5);
    // 设置不透明度
    imageView.layer.shadowOpacity = 0.5;
    NSMutableArray * images = [NSMutableArray array];
    for (int i = 7; i < 13; i ++) {
        NSString * name = [NSString stringWithFormat:@"%d.png",i];
        UIImage * img = [UIImage imageNamed:name];
        [images addObject:img];
    
    }
    imageView.animationImages = images;
    
    // 设置动画间隔,必须在startAnimating之前设置间隔
    imageView.animationDuration = 1;
    [imageView startAnimating];

    
    
    
    
    //imageView.contentMode = UIViewContentModeScaleAspectFill;
   // imageView.contentMode = UIViewContentModeTop;
    // 25把我自己的图片变成圆形,这里的25代表的是半径
    imageView.layer.cornerRadius = 25;
    [imageView.layer setMasksToBounds:YES];
    
    [self.window addSubview:imageView];
    [imageView release];
==========================

UISlider:

#pragma mark - UISlider
    UISlider * slider = [[UISlider alloc]initWithFrame:CGRectMake(50, 200, 200, 50)];
    slider.minimumValue = 100;
    slider.maximumValue = 200;
    // 设置让slider倒立(即竖直方向)
    // slider.transform = CGAffineTransformMakeRotation(M_PI_2);
    // 设置划过的区域的颜色
    slider.minimumTrackTintColor = [UIColor blackColor];
   // slider.tintColor = [UIColor redColor];
    // 设置未划过区域的颜色
    slider.maximumTrackTintColor = [UIColor redColor];
    UIImage * img = [UIImage imageNamed:@"3"];
    [slider setThumbImage:img forState:UIControlStateNormal];
    slider.thumbTintColor = [UIColor blueColor];
    
    
    [slider addTarget:self action:@selector(sliderChanged:) forControlEvents:UIControlEventValueChanged];
    [self.view addSubview:slider];
    [slider release];
=====================================

UISegment:

#pragma mark - UISegmentedControl
    NSArray * items = [NSArray arrayWithObjects:@"首页",@"列表",@"收藏", nil];
    UISegmentedControl * seg = [[UISegmentedControl alloc]initWithItems:items];
    seg.frame = CGRectMake(30, 50, 250, 30);
    seg.tintColor = [UIColor blackColor];
    [seg insertSegmentWithTitle:@"我的页面" atIndex:1 animated:YES];
    seg.selectedSegmentIndex = 2;
    [seg addTarget:self action:@selector(segClicked:) forControlEvents:UIControlEventValueChanged];
    [self.view addSubview:seg];
    [seg release];
=====================================

UIControl:

UIControl的核⼼心功能:
为控制控件通过addTarget: action: forControlEvents: ⽅方法来添加事 件。
通过removeTarget: action: forControlEvents: 来移除事件。

=====================================

小结:


UIControl是所有控制类控件的基类。 UISlider是可以响应滑动事件的控件 UISegmentedControl是可以实现单选的控件 UIImageView除了能显⽰示单张图⽚片,还能处理⼀一组图⽚片的播放

=====================================

这次太晚了,到家就要12点了~~~~~~~~~~~~






你可能感兴趣的:(ui)