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);

  • 相关阅读:
    Windows 命令行
    建议博客园提供 BT 资源发布功能——由分享 VS2005 Beta2 的历程想到的
    成功 自信 快乐(转载)
    轻松一下,加菲猫语录
    COmega 概述
    对 RBAC 几种模型的理解及初步实现构想
    DHTML 中滚动条的设置
    求婚
    终于有了自己的blog!
    VS2005 已发布!
  • 原文地址:https://www.cnblogs.com/xiangjune/p/4922573.html
Copyright © 2011-2022 走看看