美文网首页
iOS图片重复填充

iOS图片重复填充

作者: Smallwolf_JS | 来源:发表于2018-11-11 13:38 被阅读86次

    有两种方式:
    方式一:colorWithPatternImage用背景颜色设置图片

    UIImageView * imageView = [[UIImageView alloc]initWithFrame:CGRectMake(20, 100, 400, 18)];
    [self.view addSubview:imageView];
    imageView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"ico_pk_bar_blue.png"]];
    

    方式二:UIImageResizingModeTileresize图片

    UIImageView * imageView = [[UIImageView alloc]initWithFrame:CGRectMake(20, 100, 400, 18)];
        [self.view addSubview:imageView];
        UIImage *image = [UIImage imageNamed:@"ico_pk_bar_blue.png"];
    
        UIImage * newImage = [image resizableImageWithCapInsets:UIEdgeInsetsZero resizingMode:UIImageResizingModeTile];
        
        imageView.image = newImage;
    

    相关文章

      网友评论

          本文标题:iOS图片重复填充

          本文链接:https://www.haomeiwen.com/subject/dhfkzftx.html