zoukankan      html  css  js  c++  java
  • iOS常用技术-图片拉伸

     1 //
     2 //  ViewController.m
     3 //  图片拉伸
     4 //
     5 //  Created by 大欢 on 16/1/20.
     6 //  Copyright © 2016年 bjsxt. All rights reserved.
     7 //
     8 
     9 #import "ViewController.h"
    10 
    11 @interface ViewController ()
    12 
    13 @end
    14 
    15 @implementation ViewController
    16 
    17 - (void)viewDidLoad {
    18     [super viewDidLoad];
    19     
    20 //    [self exmaple1];
    21 //    [self exmaple2];
    22     
    23     UIImage * image = [UIImage imageNamed:@"button_back"];
    24     
    25     UIEdgeInsets insets = UIEdgeInsetsMake(5, 2, 5, 2);
    26     
    27     image = [image resizableImageWithCapInsets:insets resizingMode:UIImageResizingModeStretch];
    28     
    29     UIImageView * imageView = [[UIImageView alloc] initWithFrame:CGRectMake(12, 50 , self.view.frame.size.width - 24, 40)];
    30     
    31     imageView.image = image;
    32     
    33     [self.view addSubview:imageView];
    34     
    35     
    36 }
    37 
    38 - (void)exmaple2 {
    39     
    40     UIImage * image = [UIImage imageNamed:@"qipao"];
    41     
    42     UIEdgeInsets insets = UIEdgeInsetsMake(50, 35, 10, 10);
    43     
    44     image = [image resizableImageWithCapInsets:insets resizingMode:UIImageResizingModeStretch];
    45     
    46     UIImageView * imageView = [[UIImageView alloc] initWithFrame:CGRectMake(30, 50, 300, 300)];
    47     
    48     imageView.image = image;
    49     
    50     [self.view addSubview:imageView];
    51 }
    52 
    53 - (void)exmaple1 {
    54     
    55     UIImage * image = [UIImage imageNamed:@"backgroundImage"];
    56     
    57     //上,左,下,右
    58     UIEdgeInsets insets = UIEdgeInsetsMake(6, 6, 6, 6);
    59     
    60     //拉伸图片方法
    61     image = [image resizableImageWithCapInsets:insets resizingMode:UIImageResizingModeStretch];
    62     
    63     UIImageView * imageView = [[UIImageView alloc] initWithFrame:CGRectMake(20, 30, self.view.frame.size.width - 40, 30)];
    64     
    65     imageView.image = image;
    66     
    67     [self.view addSubview:imageView];
    68 }
    69 
    70 @end


    /********************************************************************/

  • 相关阅读:
    如果因特网中的所有链路都提供可靠的交付服务,TCP可靠传输服务是多余的吗?
    编译运行java程序出现Exception in thread "main" java.lang.UnsupportedClassVersionError: M : Unsupported major.minor version 51.0
    chrome浏览器插件的开启快捷键
    sqlzoo练习题答案
    2019Falg
    python绘图踩的坑
    精益数据分析--测试分析
    np.random的随机数函数
    numpy中文件的存储和读取-嵩天老师笔记
    喜欢的话
  • 原文地址:https://www.cnblogs.com/MrWuYindi/p/5146683.html
Copyright © 2011-2022 走看看