Uiimageview边界扭曲与曲折边界?

时间:2014-08-28 09:38:43

标签: ios uiimageview uicollectionview border transformation

我在我的iphone应用程序中使用UICollectionView,并且我已经通过循环方式修改了horizinatcl旋转的uicollection视图。以下是图片。enter image description here

现在我面临的问题是为什么这些图像的边界与zigzaging边界不同。 我不知道为什么会这样,为什么会这样。谁知道我怎么能解决这个图像边界的分布。

任何帮助都会很明显......

3 个答案:

答案 0 :(得分:0)

以下是创建图像和图像视图的代码,添加边框并围绕角落:

// Define a new image object
  UIImage *image = [UIImage imageNamed:@"lake.png"];

// Define a new image view
  UIImageView* imgView = [[UIImageView alloc] initWithFrame:CGRectMake(10, 10, 157, 125)];

// Set image in imageview and add to view
  [imgView setImage:image];
  [[self view] addSubview:imgView];

// Create a white border with defined width
  imgView.layer.borderColor = [UIColor whiteColor].CGColor;
  imgView.layer.borderWidth = 1.5;

// Set image corner radius
  imgView.layer.cornerRadius = 5.0;

// To enable corners to be "clipped"
  [imgView setClipsToBounds:YES];

希望这可以帮到你。

答案 1 :(得分:0)

使用您的图片尝试类似的内容

UIImage *image = [[UIImage imageNamed:[self.imgArray objectAtIndex:indexPath.row]] resizableImageWithCapInsets:UIEdgeInsetsMake(10, 10, 10, 10)];

如果需要,请更改 UIEdgeInsets 值...

答案 2 :(得分:0)

光栅化应解决此问题。 https://developer.apple.com/library/mac/documentation/GraphicsImaging/Reference/CALayer_class/#//apple_ref/occ/instp/CALayer/shouldRasterize

imageView.layer.shouldRasterize = YES; 
imageView.layer.rasterizationScale = [[UIScreen mainScreen] scale];
相关问题