zoukankan      html  css  js  c++  java
  • UIImageView

    // ----------------------------------------------UIImageView----------------------------------------------

        UIImageView *imageView = [[UIImageView alloc] init];

        imageView.image = [UIImage imageNamed:@"paper_list_homewok"];

        imageView.backgroundColor = [UIColor redColor];

        imageView.frame = CGRectMake(100, 100, 300, 300);

        

        // 加载图片方式

        //第二种:

        NSString *filePath=[[NSBundle mainBundle] pathForResource:@"1" ofType:@"jpeg"];

        UIImage *images=[UIImage imageWithContentsOfFile:filePath];

        //[imageView setImage:images];

        //第三种:

        NSData *data=[NSData dataWithContentsOfFile:filePath];

        UIImage *image2=[UIImage imageWithData:data];

        [imageView setImage:image2];

        

        // 圆角

        imageView.layer.masksToBounds = YES;

        imageView.layer.cornerRadius = 10.0;

        

        // 边框

        imageView.layer.borderColor = [UIColor orangeColor].CGColor;

        imageView.layer.borderWidth = 2;

        

        //    (4)contentMode属性:当图片小于imageView的大小处理图片显示

        imageView.contentMode = UIViewContentModeCenter;

        

        // 播放多个图片

    //    UIImage *image1 = [UIImage imageNamed:@"paper_list_homewok"];

    //    UIImage *image2 = [UIImage imageNamed:@"question_check_selected"];

    //    UIImage *image3 = [UIImage imageNamed:@"paper_list_homewok"];

    //    UIImage *image4 = [UIImage imageNamed:@"question_check_selected"];

    //    NSArray *imagesArray = @[image1,image2,image3,image4];

    //    imageView.animationImages = imagesArray;

    //    imageView.animationDuration = [imagesArray count];

    //    [imageView startAnimating];

        

        //为图片添加单击事件:一定要先将userInteractionEnabled置为YES,这样才能响应单击事件

        imageView.userInteractionEnabled = YES;

        UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapImageView:)];

        [imageView addGestureRecognizer:singleTap];

        

        // 透明度

        imageView.alpha = 0.5;

        

        imageView.highlightedImage = [UIImage imageNamed:@"question_check_selected"];

        

        // 设置图片的中心点

        imageView.center = CGPointMake(0,0);

  • 相关阅读:
    数据持久化的基础知识
    svn常用命令
    关于SVN 目录结构
    linux查看CPU信息
    一个服务器上启动两台tomcat
    centos6.0 配置SVN
    mysql插入表情
    MAC 安装 PIL
    安装freetype
    Hadoop基本文件命令
  • 原文地址:https://www.cnblogs.com/xiangjune/p/4922573.html
Copyright © 2011-2022 走看看