简体   繁体   English

如何在不牺牲图像质量的情况下,将大型png图像放入XCode上较小的自定义“圆角矩形”按钮中?

[英]How do you fit a large png image into a smaller custom Round Rect Button on XCode without losing image quality?

I am creating a button for my application that, when pressed shows an indention looking effect to make it appear that the user is clicking a real button. 我正在为我的应用程序创建一个按钮,当按下该按钮时,它会显示出压痕效果,使用户看起来好像在单击真实按钮。 It is very simple, using only an image for the default state and the depressed one for the highlighted state. 这非常简单,仅将图像用作默认状态,将按下的图像用作突出显示状态。 I'm having a few problems. 我有一些问题。 The quality is terrible. 质量太差了。 I have uploaded the images to XCode in the exact pixels they will be presented in my application but when I export it from Illustrator it gets really pixelated. 我已将图像的确切像素上载到XCode,这些像素将在我的应用程序中显示,但是当我从Illustrator导出图像时,它确实变得像素化。 So I was wondering if there was a way for me to upload an image a few times bigger than my button and have it shrink to fit the button size. 所以我想知道是否有一种方法可以上传比按钮大几倍的图像,并使其缩小以适合按钮的大小。 I've tried to do that but when I run my app it gets really messed up and weird looking. 我已经尝试过这样做,但是当我运行我的应用程序时,它真的很混乱,看起来很奇怪。 I would just put text inside the button but then it ruins the pressed effect. 我只是将文本放在按钮内,但随后会破坏按下的效果。 Any ideas? 有任何想法吗?

If you export an image at the same aspect ratio as the button, the image will be re-scaled to fit within your button. 如果以与按钮相同的宽高比导出图像,则图像将被重新缩放以适合您的按钮。 Don't forget to use the Custom style so you don't get the button oval. 不要忘记使用自定义样式,这样您就不会使按钮变成椭圆形。

However generating an exact pixel version of your button should be possible, and look good - especially if you specify a 2x sized @2x version of the image for retina use. 但是,应该可以生成按钮的精确像素版本,并且看起来不错-特别是如果您指定2x尺寸@ 2x版本的图像供视网膜使用。 Are you sure your Illustrator export settings are correct? 您确定Illustrator导出设置正确吗? One thing to consider is that perhaps anti-aliasing needs to be enabled on export. 要考虑的一件事是,可能需要在导出上启用抗锯齿。

This page has a helpful quick checklist for how to save for the iPhone from Illustrator (Scroll down to the " How To Save Art For The iPhone In Illustrator " header) 此页面提供了一个有用的快速清单,用于如何从Illustrator保存iPhone(向下滚动至“ 如何在Illustrator中保存iPhone的插图 ”标题)

http://www.vickiwenderlich.com/2011/11/faq-how-do-i-save-art-for-the-iphoneipad/ http://www.vickiwenderlich.com/2011/11/faq-how-do-i-save-art-for-the-iphoneipad/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在不损失质量的情况下调整图像大小 - Resize Image without losing quality Xcode 5中没有圆形矩形按钮? - No Round Rect Button in Xcode 5? 如何通过图像数据快速将图像上传到天蓝色而又不损失质量 - How to upload images to azure without losing quality with image data swift iOS加载调整大小的图像而不会降低质量 - iOS load resized image without losing quality 如何在不损失清晰度和清晰度的情况下调整PNG的大小? - How do you resize a PNG without losing clarity and sharpness? 如何在Xcode中为按钮设置所选图像? - How do you set the selected image for a button in Xcode? 如何创建可以更改图像(如圆角矩形)的自定义按钮 - How do i create a custom button that can change an image like rounded rect 有关如何在不丢失图像质量的情况下缩放全屏iPad图像的任何建议? - Any suggestions on how to scale a full screen iPad image without losing image quality? 如何在不旋转的情况下将大图像放入图像视图? - How to fit a large image in image view without rotating it? 圆形矩形按钮是否有一种方法可以获得完全相同的图像大小? - Is there a way the Round Rect button to take exactly the same size of an image?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM