var backbutton = UIImage(named: "locationbar_back")?.imageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal)self.navigationController!.navigationbar.backIndicatorImage = backbuttonself.navigationController!.navigationbar.backIndicatorTransitionMaskImage = backbutton
我已经尝试在导航栏中找到图像(不是很优雅)使用这个代码(任何更好的建议欢迎):
for myvIEw in self.navigationController!.navigationbar.subvIEws as [UIVIEw]{ if myvIEw.frame.wIDth == 17 //need a better way of IDentifying object { var newFrame = myvIEw.frame newFrame.origin.y = 6.0 myvIEw.frame = newFrame }}
令人沮丧的是,图像暂时在正确的地方出现,然后被恢复到原来的位置.
我试过这样说:
> vIEwDIDLoad
> vIEwWillLayoutSubvIEws
> vIEwDIDLayoutSubvIEws
> vIEwDIDAppear
没有快乐
有没有任何建议吗?
您可以通过下一个代码直接更改您的UIImage位置.原产地可以手动设置:
...var backbuttonImage = UIImage(named: "backbuttonImage")!backbuttonImage = changeImageposition(backbuttonImage,origin: CGPointMake(0,0))navigationController!.navigationbar.backIndicatorImage = backbuttonImagenavigationController!.navigationbar.backIndicatorTransitionMaskImage = backbuttonImage...func changeImageposition(image: UIImage,origin: CGPoint) -> UIImage { let size = image.size UIGraphicsBeginImageContextWithOptions(size,false,2) image.drawInRect(CGRectMake(origin.x,origin.y,size.wIDth,size.height)) let newImage = UIGraphicsGetimageFromCurrentimageContext() UIGraphicsEndImageContext() return newImage}总结
以上是内存溢出为你收集整理的在Swift中垂直居中的IndicatorImage全部内容,希望文章能够帮你解决在Swift中垂直居中的IndicatorImage所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)