UIImageView的常用方法,属性

示例代码

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void) createImageBtn
{
    //这是初始化
    UIImageView* imageView = [[UIImageView alloc] initWithFrame:CGRectMake(50, 50, 200, 200)];

    //这才是设置图片
   [imageView setImage:[UIImage imageNamed:@"7.jpg"]];
    //UIImage* icon02 = [UIImage imageNamed:@"7.jpg"];

    imageView.animationImages = [NSArray arrayWithObjects:[UIImage imageNamed:@"3.jpg"], [UIImage imageNamed:@"2.jpg"],[UIImage imageNamed:@"7.jpg"], nil];

    imageView.animationDuration = 0.3f; // 设置循环一次的时间

    imageView.animationRepeatCount = 0; // 循环的次数。设置为0时无限循环

    [imageView startAnimating]; // 开始动画

    // [oneImageView stopAnimating]; // 停止动画



    [self.view addSubview:imageView];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.

    [self createImageBtn];

}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end

心得体会

  1. 卡着我的很简单。没有搞清楚要分成初始化和设置两部分。
  2. 对于图片不能放在文件夹里,要直接放出来,怎么调用文件夹里的,有待研究。

你可能感兴趣的:(Objective-C,iOS,UI控件)