//  图1

    UIImageView *imageView =  [[UIImageView alloc] initWithFrame:CGRectMake(100, 300, 200, 74)];

    imageView.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.3];

    imageView.image = [UIImage imageNamed:@"kkk圆角矩形 1"];

    [self.view addSubview:imageView];

    

    

    UIImage *image = [UIImage imageNamed:@"kkk圆角矩形 1"];

    CGFloat top = 0;

    CGFloat left = 50;

    CGFloat bottom = 0;

    CGFloat right = 50;

     /// 顶端、左端、底部、右端分别预留距离

    UIEdgeInsets insets = UIEdgeInsetsMake(top, left, bottom, right);

     //注意:拉伸之后一定要赋值回去

    image = [image  resizableImageWithCapInsets:insets

                                   resizingMode:UIImageResizingModeStretch];

     //UIImageResizingModeStretch:`拉伸`模式,通过`拉伸`Insets指定的矩形区域来填充图片

     //UIImageResizingModeTile:`平铺`模式,通过`重复显示`Insets指定的矩形区域来填充图片

    

    //  图2

    UIImageView *imageView1 =  [[UIImageView alloc] initWithFrame:CGRectMake(100, 500, 300, 74)];

    imageView1.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.3];

    imageView1.image = image;

    [self.view addSubview:imageView1];

 

类似安卓的点9图用法

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-01-27
  • 2022-12-23
  • 2021-07-05
  • 2022-12-23
  • 2021-09-27
  • 2021-04-11
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-08-27
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-04-20
相关资源
相似解决方案