我希望我的背景成为一个图像,所以在IB中我设置一个UIImageView
,其约束大小与其UIView
相同。但是,当我在back
上选择“UINavigationBar
”时,当NavControl
弹出到上一个VC
时,这就是它在消失之前的简要信息:{{ 0}}
也就是说,UIImageView
非常大,几乎是UIView宽度的两倍,所以当它在屏幕右侧滑动时,UIImageView
的图像会在最终之前拖动消失。
我也尝试过以编程方式执行此操作,但即使我将UIImageView
的帧设置为CGRectMake(0, 0, 100, 100)
,它仍然会转到UIView
的左侧,好像UIView
的原点不是在左上角,而是略微偏离屏幕。这可能吗?如何制作图像以使图像适合屏幕并且不会熄灭?
如果它完全相关,我jpg
使用的Images.xcassets
位于UIImageView
,虽然我可以在IB中选择并显示,viewDidLoad
的图片为白色/ blank,所以在我的[UIImage imageNamed:@"hockeyIce.jpg"]
方法中,我需要指定self.imageView.image = func screenShotMethod() {
//Create the UIImage
let image = view?.snapshot
//Save it to the camera roll
UIImageWriteToSavedPhotosAlbum(image, nil, nil, nil)
self.socialShare(sharingText: "text", sharingImage: image, sharingURL:NSURL(string: "itms-apps://itunes.apple.com/app/bars/XXXXXXXX"))
}
func socialShare(#sharingText: String?, sharingImage: UIImage?, sharingURL: NSURL?) {
var sharingItems = [AnyObject]()
if let text = sharingText {
sharingItems.append(text)
}
if let image = sharingImage {
sharingItems.append(image)
}
if let url = sharingURL {
sharingItems.append(url)
}
let activityViewController = UIActivityViewController(activityItems: sharingItems, applicationActivities: nil)
activityViewController.excludedActivityTypes = [UIActivityTypeCopyToPasteboard,UIActivityTypeAirDrop,UIActivityTypeAddToReadingList,UIActivityTypeAssignToContact,UIActivityTypePostToTencentWeibo,UIActivityTypePostToVimeo,UIActivityTypePrint,UIActivityTypeSaveToCameraRoll,UIActivityTypePostToWeibo]
var currentViewController:UIViewController=UIApplication.sharedApplication().keyWindow!.rootViewController!
currentViewController.presentViewController(activityViewController, animated: true, completion: nil)
shareButton.alpha = 1.0
}
。
答案 0 :(得分:1)
答案 1 :(得分:0)
OK, the solution was to add [self.imageView setClipsToBounds:YES]
to my viewDidLoad
. It turns out that this is a common problem with aspectFill.