【发布时间】:2014-07-22 08:39:12
【问题描述】:
我正在编写自己的键盘,我需要按钮彼此保持距离,所以我需要为我的 UIImage 添加不可见的边框,所以这是我的代码
func imageWithBorderForImage(initalImage: UIImage, withWidth width: CGFloat, withHeight height: CGFloat) -> UIImage {
UIGraphicsBeginImageContext(CGSizeMake(width , height));
initalImage.drawInRect(CGRectMake(borderSize, borderSize, width - borderSize * 2, height - borderSize));
let resultedImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return resultedImage
}
此代码按我的预期在顶部和左侧添加边框,但在底部和右侧它会剪切我的图像。那么哪里出了问题谁知道呢?
【问题讨论】: