在iPhone / Objective-C上制作精美设计视图的提示和技巧

时间:2021-04-11 19:55:50

What programming tips / tricks have you learned for styling views on the iPhone?

您在iPhone的样式视图中学到了哪些编程提示/技巧?

As an example, you can set the background color of a view to an image:

例如,您可以将视图的背景颜色设置为图像:

[myView setBackgroundColor:[UIColor colorWithPatternImage: [UIImage imageNamed:@"view-background.png"]]];

[myView setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@“view-background.png”]]];

1 个解决方案

#1


1  

I've created a bunch of custom views on the iPhone, and I generally design them in Adobe Fireworks before trying to create them in IB or XCode. Firework's native format is PNG, so it's easy to jump between the images and the simulator, and adjust them to make the view look good.

我在iPhone上创建了一堆自定义视图,我通常在尝试在IB或XCode中创建它们之前在Adobe Fireworks中设计它们。 Firework的原生格式是PNG,因此很容易在图像和模拟器之间跳转,并调整它们以使视图看起来很好。

As far as creating the actual views, I'd recommend using a UIImageView as the base class for any view that needs a custom background image. Also, to make a view transparent or semi-transparent, you need to set both opaque=NO and backgroundCoor = [UIColor clearColor].

至于创建实际视图,我建议使用UIImageView作为需要自定义背景图像的任何视图的基类。另外,要使视图透明或半透明,您需要设置opaque = NO和backgroundCoor = [UIColor clearColor]。

Hope that helps!

希望有所帮助!

#1


1  

I've created a bunch of custom views on the iPhone, and I generally design them in Adobe Fireworks before trying to create them in IB or XCode. Firework's native format is PNG, so it's easy to jump between the images and the simulator, and adjust them to make the view look good.

我在iPhone上创建了一堆自定义视图,我通常在尝试在IB或XCode中创建它们之前在Adobe Fireworks中设计它们。 Firework的原生格式是PNG,因此很容易在图像和模拟器之间跳转,并调整它们以使视图看起来很好。

As far as creating the actual views, I'd recommend using a UIImageView as the base class for any view that needs a custom background image. Also, to make a view transparent or semi-transparent, you need to set both opaque=NO and backgroundCoor = [UIColor clearColor].

至于创建实际视图,我建议使用UIImageView作为需要自定义背景图像的任何视图的基类。另外,要使视图透明或半透明,您需要设置opaque = NO和backgroundCoor = [UIColor clearColor]。

Hope that helps!

希望有所帮助!