iOS应用程式的有效UI造型[已关闭]

我的问题是一个简单的问题.在 android中,我们可以将xml样式表从布局中分离出来,以便可以随时重用,并轻松地编辑UI设计更改.

是否也可能在iOS xcode?如果可以如何(喜欢不是从控制器)?需要图书馆?什么是好的图书馆?

谢谢您的回答.

解决方法

您可以为此目的使用 UICategory类的UIView类.为设置边框,边框颜色,通过路径,拐角半径等创建不同的方法.这只是他们中的少数.类别是UIView,所以你可以使用按钮,lables,textview,textedits等;

UIView category.h

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

@end

UIView类别

@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 16 更新版本时,我们听到了困扰 Apple...
欧版/美版 特别说一下,美版选错了 可能会永久丧失4G,不过只...
一般在接外包的时候, 通常第三方需要安装你的app进行测...
前言为了让更多的人永远记住12月13日,各大厂都在这一天将应...