适用于iOS应用的有效UI样式 [英] effective UI styling for iOS app

查看:116
本文介绍了适用于iOS应用的有效UI样式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题很简单.在android中,我们可以将xml样式表与布局分开,以便可以在任何地方重复使用,并且可以轻松地进行UI设计更改进行编辑.

My question is a simple one. In android, we can separate xml stylesheet from layout so that it can be reuse everywhere and edited easily for UI design change.

在iOS xcode中也可以吗?如果可以的话(最好不要从控制器那里来)?需要图书馆吗?有什么好的图书馆?

Is it also possible in iOS xcode? if can how (prefer if not from controller)? need libraries? what are good libraries for that?

谢谢您的回答.

推荐答案

,您可以使用 UICategory 类.为set bordersborder colors,传递bazier-pathscorner radius等创建不同的方法.这只是其中的几个.类别是UIView,因此您可以在buttonslablestextviewtextedits等上使用;

you can use UICategory class for UIView for that purpose. create different methods for set borders, border colors , pass bazier-paths, corner radius and so many . this is just few of them. category is of UIView so you can use on buttons,lables,textview,textedits etc;

UIView + category.h

@interface UIView (category)
-(void)makeToRoundEdgeWithBorder:(CGFloat )borderwidth bordecolor:(UIColor *)color;

@end

UIView + category.m

@implementation UIView (category)

-(void)makeToRoundEdgeWithBorder:(CGFloat )borderwidth bordecolor:(UIColor *)color
{
   NSLog(@"height %f width %f",CGRectGetHeight(self.frame),CGRectGetWidth(self.frame));
    self.layer.cornerRadius=CGRectGetHeight(self.frame)/2;
    self.layer.masksToBounds=YES;
    self.layer.borderColor=[color CGColor];
    self.layer.borderWidth=borderwidth;
}

@end

使用

[yourlable makeToRoundEdgeWithBorder:0.0f bordercolor:[UIColor clearColor] cornerRadius:8.0f];

[yourbutton makeToRoundEdgeWithBorder:0.0f bordercolor:[UIColor clearColor] cornerRadius:8.0f];

[yourTextview makeToRoundEdgeWithBorder:0.0f bordercolor:[UIColor clearColor] cornerRadius:8.0f];

[yourTextfield makeToRoundEdgeWithBorder:0.0f bordercolor:[UIColor clearColor] cornerRadius:8.0f];

这篇关于适用于iOS应用的有效UI样式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆