#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface SK_FactoryTool : NSObject
+ (UIView *)creViewFrame:(CGRect)frame
color:(UIColor *)color
targetView:(UIView *)targetView;
+ (UIView *)creLblFrame:(CGRect)frame
title:(NSString *)title
fontSize:(CGFloat)fontSize
alignment:(NSTextAlignment)alignment
textColor:(UIColor *)textColor
bgColor:(UIColor *)bgColor
targetView:(UIView *)targetView;
+ (UIButton *)creBtnFrame:(CGRect)frame
title:(NSString *)title
titleColor:(UIColor *)titleColor
fontSize:(CGFloat)fontSize
bgColor:(UIColor *)bgColor
backgroundImage:(NSString *)imageStr
targetView:(UIView *)targetView;
+ (UIImageView *)creImgViewFrame:(CGRect)frame
imageStr:(NSString *)imageStr
targetView:(UIView *)targetView;
+ (UITextField *)creTextFieldFrame:(CGRect)frame
fontSize:(CGFloat)fontSize
holder:(NSString *)holder
targetView:(UIView *)targetView;
+ (UITextView *)creTextViewFrame:(CGRect)frame
fontSize:(CGFloat)fontSize
targetView:(UIView *)targetView;
+ (UIView *)createLeftTitleHeaderViewWithTitle:(NSString *)title color:(UIColor *)color fontSize:(CGFloat)fontSize leftPadding:(CGFloat)leftPadding;
@end
NS_ASSUME_NONNULL_END
#import "SK_FactoryTool.h"
@implementation SK_FactoryTool
+ (UIView *)creViewFrame:(CGRect)frame
color:(UIColor *)color
targetView:(UIView *)targetView
{
UIView *view;
if (CGRectEqualToRect(frame, CGRectZero)) {
view = [[UIView alloc]init];
}else{
view = [[UIView alloc]initWithFrame:frame];
}
view.backgroundColor = color;
[targetView addSubview:view];
return view;
}
+ (UIView *)creLblFrame:(CGRect)frame
title:(NSString *)title
fontSize:(CGFloat)fontSize
alignment:(NSTextAlignment)alignment
textColor:(UIColor *)textColor
bgColor:(UIColor *)bgColor
targetView:(UIView *)targetView;
{
UILabel *lbl;
if (CGRectEqualToRect(frame, CGRectZero)) {
lbl = [[UILabel alloc]init];
}else{
lbl = [[UILabel alloc]initWithFrame:frame];
}
lbl.text = title;
lbl.font = [UIFont systemFontOfSize:fontSize];
lbl.textAlignment = alignment;
lbl.textColor = textColor;
lbl.backgroundColor = bgColor;
[targetView addSubview:lbl];
return lbl;
}
+ (UIButton *)creBtnFrame:(CGRect)frame
title:(NSString *)title
titleColor:(UIColor *)titleColor
fontSize:(CGFloat)fontSize
bgColor:(UIColor *)bgColor
backgroundImage:(NSString *)imageStr
targetView:(UIView *)targetView;
{
UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
[btn setTitle:title forState:UIControlStateNormal];
[btn setTitleColor:titleColor forState:UIControlStateNormal];
btn.titleLabel.font = [UIFont systemFontOfSize:fontSize];
btn.backgroundColor = bgColor;
[targetView addSubview:btn];
if (imageStr.length != 0) {
[btn setImage:[UIImage imageNamed:imageStr] forState:UIControlStateNormal];
}
if (CGRectEqualToRect(frame,CGRectZero)) {
btn.frame = CGRectZero;
}else{
btn.frame = frame;
}
return btn;
}
+ (UIImageView *)creImgViewFrame:(CGRect)frame
imageStr:(NSString *)imageStr
targetView:(UIView *)targetView
{
UIImageView *imgView;
if (CGRectEqualToRect(frame, CGRectZero)) {
imgView = [[UIImageView alloc]init];
}else{
imgView = [[UIImageView alloc]initWithFrame:frame];
}
imgView.image = [UIImage imageNamed:imageStr];
[targetView addSubview:imgView];
return imgView;
}
+ (UITextField *)creTextFieldFrame:(CGRect)frame
fontSize:(CGFloat)fontSize
holder:(NSString *)holder
targetView:(UIView *)targetView
{
UITextField *textField;
if (CGRectEqualToRect(frame, CGRectZero)) {
textField = [[UITextField alloc]init];
}else{
textField = [[UITextField alloc]initWithFrame:frame];
}
textField.borderStyle = UITextBorderStyleRoundedRect;
textField.placeholder = holder;
textField.font = [UIFont systemFontOfSize:fontSize];
[targetView addSubview:textField];
return textField;
}
+ (UITextView *)creTextViewFrame:(CGRect)frame
fontSize:(CGFloat)fontSize
targetView:(UIView *)targetView
{
UITextView *textView;
if (CGRectEqualToRect(frame, CGRectZero)) {
textView = [[UITextView alloc]init];
}else{
textView = [[UITextView alloc] initWithFrame:frame];
}
textView.font = [UIFont systemFontOfSize:fontSize];
textView.layer.borderColor =[UIColor colorWithRed:210/255.f green:210/255.f blue:210/255.f alpha:1].CGColor;
textView.layer.borderWidth = 0.6;
textView.layer.cornerRadius = 2;
textView.layer.masksToBounds = YES;
[targetView addSubview:textView];
return textView;
}
+ (UIView *)createLeftTitleHeaderViewWithTitle:(NSString *)title color:(UIColor *)color fontSize:(CGFloat)fontSize leftPadding:(CGFloat)leftPadding
{
UIView *bgView = [[UIView alloc]init];
bgView.backgroundColor = [UIColor colorWithRed:255/255.0f green:255/255.0f blue:255/255.0f alpha:1];
bgView.frame = CGRectMake(0, 0, SCREEN_WIDTH, 50);
UIView *sepView1 = [[UIView alloc]init];
sepView1.backgroundColor = [UIColor colorWithRed:240/255.0f green:240/255.0f blue:240/255.0f alpha:1];
sepView1.frame = CGRectMake(0, 49, SCREEN_WIDTH, 1);
[bgView addSubview:sepView1];
UILabel *titleLbl = [[UILabel alloc]init];
titleLbl.font = [UIFont systemFontOfSize:fontSize];
titleLbl.textAlignment = 0;
titleLbl.textColor = color;
titleLbl.text = title;
titleLbl.userInteractionEnabled = YES;
titleLbl.frame = CGRectMake(leftPadding, 0, SCREEN_WIDTH - leftPadding * 2, 49);
[bgView addSubview:titleLbl] ;
return bgView;
}
@end