Commit 6a62d1f5 by xuning

手机号登录、验证码登录UI

parent 229b1a8c
......@@ -7,6 +7,10 @@
objects = {
/* Begin PBXBuildFile section */
7981EAB72B6E669000F357E7 /* UIScrollView+XVAdd.m in Sources */ = {isa = PBXBuildFile; fileRef = 7981EAB62B6E669000F357E7 /* UIScrollView+XVAdd.m */; };
7981EABA2B6E670200F357E7 /* UIView+XVAdd.m in Sources */ = {isa = PBXBuildFile; fileRef = 7981EAB92B6E670200F357E7 /* UIView+XVAdd.m */; };
7981EABD2B6E675F00F357E7 /* NSString+XVAdd.m in Sources */ = {isa = PBXBuildFile; fileRef = 7981EABC2B6E675F00F357E7 /* NSString+XVAdd.m */; };
7981EAC42B6E800900F357E7 /* XVInputFieldView.m in Sources */ = {isa = PBXBuildFile; fileRef = 7981EAC22B6E800900F357E7 /* XVInputFieldView.m */; };
799DF0C62B6BD8AF00680907 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 799DF0C52B6BD8AF00680907 /* AppDelegate.m */; };
799DF0D12B6BD8B100680907 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 799DF0D02B6BD8B100680907 /* Assets.xcassets */; };
799DF0D42B6BD8B100680907 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 799DF0D22B6BD8B100680907 /* LaunchScreen.storyboard */; };
......@@ -21,7 +25,6 @@
799DF10F2B6D25B400680907 /* UINavigation+SXFixSpace.m in Sources */ = {isa = PBXBuildFile; fileRef = 799DF10C2B6D25B400680907 /* UINavigation+SXFixSpace.m */; };
799DF1102B6D25B400680907 /* UIBarButtonItem+SXCreate.m in Sources */ = {isa = PBXBuildFile; fileRef = 799DF10D2B6D25B400680907 /* UIBarButtonItem+SXCreate.m */; };
799DF1112B6D25B400680907 /* NSObject+SXRuntime.m in Sources */ = {isa = PBXBuildFile; fileRef = 799DF10E2B6D25B400680907 /* NSObject+SXRuntime.m */; };
799DF1152B6D284100680907 /* XVInputFieldView.m in Sources */ = {isa = PBXBuildFile; fileRef = 799DF1142B6D284100680907 /* XVInputFieldView.m */; };
799DF11A2B6D2B3200680907 /* XVLoginViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 799DF1192B6D2B3200680907 /* XVLoginViewController.m */; };
FA5E55D5A48FDC04BA4CCD08 /* Pods_fastservice.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 08D109EE60B32403F3655A70 /* Pods_fastservice.framework */; };
/* End PBXBuildFile section */
......@@ -30,6 +33,14 @@
08D109EE60B32403F3655A70 /* Pods_fastservice.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_fastservice.framework; sourceTree = BUILT_PRODUCTS_DIR; };
0A560A1F356C4AB4EE319B53 /* Pods-fastservice.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-fastservice.debug.xcconfig"; path = "Target Support Files/Pods-fastservice/Pods-fastservice.debug.xcconfig"; sourceTree = "<group>"; };
6102ECAEC07A0BE24F1B6143 /* Pods-fastservice.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-fastservice.release.xcconfig"; path = "Target Support Files/Pods-fastservice/Pods-fastservice.release.xcconfig"; sourceTree = "<group>"; };
7981EAB52B6E669000F357E7 /* UIScrollView+XVAdd.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "UIScrollView+XVAdd.h"; sourceTree = "<group>"; };
7981EAB62B6E669000F357E7 /* UIScrollView+XVAdd.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "UIScrollView+XVAdd.m"; sourceTree = "<group>"; };
7981EAB82B6E670200F357E7 /* UIView+XVAdd.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "UIView+XVAdd.h"; sourceTree = "<group>"; };
7981EAB92B6E670200F357E7 /* UIView+XVAdd.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "UIView+XVAdd.m"; sourceTree = "<group>"; };
7981EABB2B6E675F00F357E7 /* NSString+XVAdd.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "NSString+XVAdd.h"; sourceTree = "<group>"; };
7981EABC2B6E675F00F357E7 /* NSString+XVAdd.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "NSString+XVAdd.m"; sourceTree = "<group>"; };
7981EAC22B6E800900F357E7 /* XVInputFieldView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = XVInputFieldView.m; sourceTree = "<group>"; };
7981EAC32B6E800900F357E7 /* XVInputFieldView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XVInputFieldView.h; sourceTree = "<group>"; };
799DF0C12B6BD8AF00680907 /* fastservice.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = fastservice.app; sourceTree = BUILT_PRODUCTS_DIR; };
799DF0C42B6BD8AF00680907 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
799DF0C52B6BD8AF00680907 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
......@@ -58,8 +69,6 @@
799DF10C2B6D25B400680907 /* UINavigation+SXFixSpace.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UINavigation+SXFixSpace.m"; sourceTree = "<group>"; };
799DF10D2B6D25B400680907 /* UIBarButtonItem+SXCreate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIBarButtonItem+SXCreate.m"; sourceTree = "<group>"; };
799DF10E2B6D25B400680907 /* NSObject+SXRuntime.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSObject+SXRuntime.m"; sourceTree = "<group>"; };
799DF1132B6D284100680907 /* XVInputFieldView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XVInputFieldView.h; sourceTree = "<group>"; };
799DF1142B6D284100680907 /* XVInputFieldView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XVInputFieldView.m; sourceTree = "<group>"; };
799DF1182B6D2B3200680907 /* XVLoginViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XVLoginViewController.h; sourceTree = "<group>"; };
799DF1192B6D2B3200680907 /* XVLoginViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XVLoginViewController.m; sourceTree = "<group>"; };
/* End PBXFileReference section */
......@@ -85,6 +94,15 @@
path = Pods;
sourceTree = "<group>";
};
7981EABE2B6E7B3700F357E7 /* View */ = {
isa = PBXGroup;
children = (
7981EAC32B6E800900F357E7 /* XVInputFieldView.h */,
7981EAC22B6E800900F357E7 /* XVInputFieldView.m */,
);
path = View;
sourceTree = "<group>";
};
799DF0B82B6BD8AE00680907 = {
isa = PBXGroup;
children = (
......@@ -142,6 +160,12 @@
children = (
799DF0E02B6BDA1300680907 /* BRPlaceholderTextView.h */,
799DF0E12B6BDA1300680907 /* BRPlaceholderTextView.m */,
7981EAB52B6E669000F357E7 /* UIScrollView+XVAdd.h */,
7981EAB62B6E669000F357E7 /* UIScrollView+XVAdd.m */,
7981EAB82B6E670200F357E7 /* UIView+XVAdd.h */,
7981EAB92B6E670200F357E7 /* UIView+XVAdd.m */,
7981EABB2B6E675F00F357E7 /* NSString+XVAdd.h */,
7981EABC2B6E675F00F357E7 /* NSString+XVAdd.m */,
);
path = Categpry;
sourceTree = "<group>";
......@@ -189,7 +213,6 @@
799DF0F12B6BDA1400680907 /* Base */ = {
isa = PBXGroup;
children = (
799DF1122B6D281000680907 /* View */,
799DF0F22B6BDA1400680907 /* Controller */,
);
path = Base;
......@@ -219,18 +242,10 @@
path = "UINavigation+SXFixSpace";
sourceTree = "<group>";
};
799DF1122B6D281000680907 /* View */ = {
isa = PBXGroup;
children = (
799DF1132B6D284100680907 /* XVInputFieldView.h */,
799DF1142B6D284100680907 /* XVInputFieldView.m */,
);
path = View;
sourceTree = "<group>";
};
799DF1162B6D2B1300680907 /* Login */ = {
isa = PBXGroup;
children = (
7981EABE2B6E7B3700F357E7 /* View */,
799DF1172B6D2B1B00680907 /* Controller */,
);
path = Login;
......@@ -386,13 +401,16 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
7981EAB72B6E669000F357E7 /* UIScrollView+XVAdd.m in Sources */,
799DF1042B6D220300680907 /* XVBaseViewController.m in Sources */,
799DF0C62B6BD8AF00680907 /* AppDelegate.m in Sources */,
799DF1112B6D25B400680907 /* NSObject+SXRuntime.m in Sources */,
799DF1152B6D284100680907 /* XVInputFieldView.m in Sources */,
7981EABA2B6E670200F357E7 /* UIView+XVAdd.m in Sources */,
7981EABD2B6E675F00F357E7 /* NSString+XVAdd.m in Sources */,
799DF0F72B6BDA1400680907 /* BRPlaceholderTextView.m in Sources */,
799DF0F82B6BDA1400680907 /* NSString+Unicode.m in Sources */,
799DF0D72B6BD8B100680907 /* main.m in Sources */,
7981EAC42B6E800900F357E7 /* XVInputFieldView.m in Sources */,
799DF11A2B6D2B3200680907 /* XVLoginViewController.m in Sources */,
799DF0FB2B6BDA1400680907 /* WRNavigationBar.m in Sources */,
799DF1102B6D25B400680907 /* UIBarButtonItem+SXCreate.m in Sources */,
......@@ -539,7 +557,7 @@
GCC_PREFIX_HEADER = "$(SRCROOT)/fastservice/PrefixHeader.pch";
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = fastservice/Info.plist;
INFOPLIST_KEY_CFBundleDisplayName = "$(PRODUCT_NAME)";
INFOPLIST_KEY_CFBundleDisplayName = "快服务";
INFOPLIST_KEY_NSLocationWhenInUseUsageDescription = "此APP需要访问您的位置,用于展示当前定位";
INFOPLIST_KEY_NSPhotoLibraryUsageDescription = "此APP需要访问您的相册,用于上传附件";
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
......@@ -572,7 +590,7 @@
GCC_PREFIX_HEADER = "$(SRCROOT)/fastservice/PrefixHeader.pch";
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = fastservice/Info.plist;
INFOPLIST_KEY_CFBundleDisplayName = "$(PRODUCT_NAME)";
INFOPLIST_KEY_CFBundleDisplayName = "快服务";
INFOPLIST_KEY_NSLocationWhenInUseUsageDescription = "此APP需要访问您的位置,用于展示当前定位";
INFOPLIST_KEY_NSPhotoLibraryUsageDescription = "此APP需要访问您的相册,用于上传附件";
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
......
......@@ -9,6 +9,7 @@
#import <AvoidCrash.h>
#import <IQKeyboardManager/IQKeyboardManager.h>
#import "XVLoginViewController.h"
#import "XVNaviViewController.h"
@interface AppDelegate ()
......@@ -29,10 +30,12 @@
// 设置主窗口,并设置根控制器
self.window = [[UIWindow alloc]initWithFrame:[UIScreen mainScreen].bounds];
XVLoginViewController *vc = [[XVLoginViewController alloc]init];
XVNaviViewController *navi = [[XVNaviViewController alloc]initWithRootViewController:vc];
self.window.rootViewController = vc;
self.window.rootViewController = navi;
self.window.backgroundColor = [UIColor redColor];
[self.window makeKeyAndVisible];
......
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "closeeyes@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "closeeyes@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "openeyes@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "openeyes@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "order_check box@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "order_check box@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "order_checkSelect@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "order_checkSelect@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "right.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
//
// XVInputFieldView.m
// fastservice
//
// Created by xuning on 2/2/24.
// Copyright © 2024 FastService. All rights reserved.
//
#import "XVInputFieldView.h"
@implementation XVInputFieldView
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
// Drawing code
}
*/
@end
//
// NSString+XVAdd.h
// fastservice
//
// Created by xuning on 2/3/24.
// Copyright © 2024 FastService. All rights reserved.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@interface NSString (XVAdd)
-(CGFloat)getSpaceLabelHeightwithSpeace:(CGFloat)lineSpeace withFont:(UIFont*)font withWidth:(CGFloat)width;
/**
获取指定宽度width,字体大小fontSize,字符串value的高度
@param text 文本
@param font 字体大小
@param width 限制字符串显示区域的宽度
@return 返回的高度
*/
- (CGFloat)heightForString:(NSString *)text font:(UIFont *)font width:(CGFloat)width;
/**
* 计算当前字符串的size
*
* @param font 使用的字体
* @param maxSize 最大的size
*
* @return 需要的最小size
*/
- (CGSize)sizeWithFont:(UIFont *)font maxSize:(CGSize)maxSize;
@end
NS_ASSUME_NONNULL_END
//
// NSString+XVAdd.m
// fastservice
//
// Created by xuning on 2/3/24.
// Copyright © 2024 FastService. All rights reserved.
//
#import "NSString+XVAdd.h"
@implementation NSString (XVAdd)
- (CGFloat)heightForString:(NSString *)text font:(UIFont *)font width:(CGFloat)width {
NSDictionary *attributes = @{NSFontAttributeName : font};
CGSize sizeToFit = [text boundingRectWithSize:CGSizeMake(width, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin attributes:attributes context:nil].size;
return sizeToFit.height;
}
/**
* 计算当前字符串的size
*
* @param font 使用的字体
* @param maxSize 最大的size
*
* @return 需要的最小size
*/
- (CGSize)sizeWithFont:(UIFont *)font maxSize:(CGSize)maxSize
{
CGSize size = CGSizeZero;
if ([self respondsToSelector:@selector(boundingRectWithSize:options:attributes:context:)]) {
size = [self boundingRectWithSize:maxSize options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName : font} context:nil].size;
}
//额外增加一个点,防止计算误差
return CGSizeMake(size.width + 1, size.height);
}
/**
* 计算富文本字体高度
*
* @param lineSpeace 行高
* @param font 字体
* @param width 字体所占宽度
*
* @return 富文本高度
*/
-(CGFloat)getSpaceLabelHeightwithSpeace:(CGFloat)lineSpeace withFont:(UIFont*)font withWidth:(CGFloat)width {
NSMutableParagraphStyle *paraStyle = [[NSMutableParagraphStyle alloc] init];
// paraStyle.lineBreakMode = NSLineBreakByCharWrapping;
/** 行高 */
paraStyle.lineSpacing = lineSpeace;
// NSKernAttributeName字体间距
NSDictionary *dic = @{NSFontAttributeName:font, NSParagraphStyleAttributeName:paraStyle};
CGSize size = [self boundingRectWithSize:CGSizeMake(width,MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin attributes:dic context:nil].size;
return size.height;
}
@end
//
// XVInputFieldView.h
// UIScrollView+XVAdd.h
// fastservice
//
// Created by xuning on 2/2/24.
// Created by xuning on 2/3/24.
// Copyright © 2024 FastService. All rights reserved.
//
......@@ -10,7 +10,12 @@
NS_ASSUME_NONNULL_BEGIN
@interface XVInputFieldView : UIView
@interface UICollectionView (XVAdd)
@end
@interface UIScrollView (XVAdd)
@end
......
//
// UIScrollView+XVAdd.m
// fastservice
//
// Created by xuning on 2/3/24.
// Copyright © 2024 FastService. All rights reserved.
//
#import "UIScrollView+XVAdd.h"
@implementation UICollectionView (XVAdd)
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer {
if ([self panBack:gestureRecognizer]) {
return YES;
}
return NO;
}
-(BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer {
if ([self panBack:gestureRecognizer]) {
return NO;
}
return YES;
}
- (BOOL)panBack:(UIGestureRecognizer *)gestureRecognizer {
if (gestureRecognizer == self.panGestureRecognizer) {
UIPanGestureRecognizer *pan = (UIPanGestureRecognizer *)gestureRecognizer;
CGPoint point = [pan translationInView:self];
UIGestureRecognizerState state = gestureRecognizer.state;
if (UIGestureRecognizerStateBegan == state || UIGestureRecognizerStatePossible == state) {
CGPoint location = [gestureRecognizer locationInView:self];
if (point.x > 0 && location.x < 90 && self.contentOffset.x <= 0) {
return YES;
}
}
}
return NO;
}
@end
@implementation UIScrollView (XVAdd)
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer {
if ([self panBack:gestureRecognizer]) {
return YES;
}
return NO;
}
-(BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer {
if ([self panBack:gestureRecognizer]) {
return NO;
}
return YES;
}
- (BOOL)panBack:(UIGestureRecognizer *)gestureRecognizer {
if (gestureRecognizer == self.panGestureRecognizer) {
UIPanGestureRecognizer *pan = (UIPanGestureRecognizer *)gestureRecognizer;
CGPoint point = [pan translationInView:self];
UIGestureRecognizerState state = gestureRecognizer.state;
if (UIGestureRecognizerStateBegan == state || UIGestureRecognizerStatePossible == state) {
CGPoint location = [gestureRecognizer locationInView:self];
if (point.x > 0 && location.x < 90 && self.contentOffset.x <= 0) {
return YES;
}
}
}
return NO;
}
@end
//
// UIView+XVAdd.h
// fastservice
//
// Created by xuning on 2/3/24.
// Copyright © 2024 FastService. All rights reserved.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface UIView (XVAdd)
#pragma mark - 设置部分圆角
/**
* 设置部分圆角(绝对布局)
*
* @param corners 需要设置为圆角的角 UIRectCornerTopLeft | UIRectCornerTopRight | UIRectCornerBottomLeft | UIRectCornerBottomRight | UIRectCornerAllCorners
* @param radii 需要设置的圆角大小 例如 CGSizeMake(20.0f, 20.0f)
*/
- (void)addRoundedCorners:(UIRectCorner)corners
withRadii:(CGSize)radii;
/**
* 设置部分圆角(相对布局)
*
* @param corners 需要设置为圆角的角 UIRectCornerTopLeft | UIRectCornerTopRight | UIRectCornerBottomLeft | UIRectCornerBottomRight | UIRectCornerAllCorners
* @param radii 需要设置的圆角大小 例如 CGSizeMake(20.0f, 20.0f)
* @param rect 需要设置的圆角view的rect
*/
- (void)addRoundedCorners:(UIRectCorner)corners
withRadii:(CGSize)radii
viewRect:(CGRect)rect;
@end
@interface UILabel (XVAdd)
/**
便利构造函数
@param text text description
@param color color description
@param alignment alignment description
@param size size description
@return YDLable
*/
- (instancetype)initWithText:(NSString *)text textColor:(UIColor *)color textAlignment:(NSTextAlignment)alignment fontSize:(CGFloat)size;
/**
* 改变行间距
*/
+ (void)changeLineSpaceForLabel:(UILabel *)label WithSpace:(float)space;
/**
* 改变字间距
*/
+ (void)changeWordSpaceForLabel:(UILabel *)label WithSpace:(float)space;
/**
* 改变行间距和字间距
*/
+ (void)changeSpaceForLabel:(UILabel *)label withLineSpace:(float)lineSpace WordSpace:(float)wordSpace;
@end
@interface UIButton (XVAdd)
/**
自定义响应边界 UIEdgeInsetsMake(-3, -4, -5, -6). 表示扩大
例如: self.btn.hitEdgeInsets = UIEdgeInsetsMake(-3, -4, -5, -6);
*/
@property(nonatomic, assign) UIEdgeInsets hitEdgeInsets;
/**
自定义响应边界 自定义的边界的范围 范围扩大3.0,frame 必须是确定的!
如果没有效果,请打印frame
例如:self.btn.hitScale = 3.0;
*/
@property(nonatomic, assign) CGFloat hitScale;
/*
自定义响应边界 自定义的宽度的范围 范围扩大3.0 frame 必须是确定的!
如果没有效果,请打印frame
例如:self.btn.hitWidthScale = 3.0;
*/
@property(nonatomic, assign) CGFloat hitWidthScale;
/*
自定义响应边界 自定义的高度的范围 范围扩大3.0 frame 必须是确定的!
如果没有效果,请打印frame
例如:self.btn.hitHeightScale = 3.0;
*/
@property(nonatomic, assign) CGFloat hitHeightScale;
/**
便利构造函数
@param title title description
@param size size description
@param titleColor titleColor description
@param imageName imageName description
@param selectedImgName selectedImgName description
@param backgroundColor backgroundColor description
@return YDButton
*/
- (instancetype)initWithTitle:(NSString *)title fontSize:(CGFloat)size titleColor:(UIColor *)titleColor normalImageName:(NSString *)imageName selectedImgName:(NSString *)selectedImgName backgroundColor:(UIColor *)backgroundColor;
- (instancetype)initWithTitle:(NSString *)title fontSize:(CGFloat)size normalTitleColor:(UIColor *)normalTitleColor selectTitleColor:(UIColor *)selectTitleColor normalImgColor:(UIColor *)normalImgColor selectedImgColor:(UIColor *)selectedImgColor;
- (instancetype)initWithTitle:(NSString *)title fontSize:(CGFloat)size titleColor:(UIColor *)titleColor bgColor:(UIColor *)bgColor;
- (instancetype)initWithNormalImageName:(NSString *)imageName selectedImgName:(NSString *)selectedImgName;
// 设置左字右图
- (void)setForceRightToLeft:(CGFloat)spacing forState:(UIControlState)state;
@end
@interface UIImageView (XVAdd)
/**
便利构造函数
@param imageNamed imageName description
@return YDImageView
*/
- (instancetype)initWithImageName:(NSString *)imageNamed;
@end
NS_ASSUME_NONNULL_END
//
// UIView+XVAdd.m
// fastservice
//
// Created by xuning on 2/3/24.
// Copyright © 2024 FastService. All rights reserved.
//
#import "UIView+XVAdd.h"
#import <objc/runtime.h>
static const char * kHitEdgeInsets = "hitEdgeInsets";
static const char * kHitScale = "hitScale";
static const char * kHitWidthScale = "hitWidthScale";
static const char * kHitHeightScale = "hitHeightScale";
@implementation UIView (XVAdd)
#pragma mark - 设置部分圆角
/**
* 设置部分圆角(绝对布局)
*
* @param corners 需要设置为圆角的角 UIRectCornerTopLeft | UIRectCornerTopRight | UIRectCornerBottomLeft | UIRectCornerBottomRight | UIRectCornerAllCorners
* @param radii 需要设置的圆角大小 例如 CGSizeMake(20.0f, 20.0f)
*/
- (void)addRoundedCorners:(UIRectCorner)corners
withRadii:(CGSize)radii {
UIBezierPath* rounded = [UIBezierPath bezierPathWithRoundedRect:self.bounds byRoundingCorners:corners cornerRadii:radii];
CAShapeLayer* shape = [[CAShapeLayer alloc] init];
[shape setPath:rounded.CGPath];
self.layer.mask = shape;
}
/**
* 设置部分圆角(相对布局)
*
* @param corners 需要设置为圆角的角 UIRectCornerTopLeft | UIRectCornerTopRight | UIRectCornerBottomLeft | UIRectCornerBottomRight | UIRectCornerAllCorners
* @param radii 需要设置的圆角大小 例如 CGSizeMake(20.0f, 20.0f)
* @param rect 需要设置的圆角view的rect
*/
- (void)addRoundedCorners:(UIRectCorner)corners
withRadii:(CGSize)radii
viewRect:(CGRect)rect {
UIBezierPath* rounded = [UIBezierPath bezierPathWithRoundedRect:rect byRoundingCorners:corners cornerRadii:radii];
CAShapeLayer* shape = [[CAShapeLayer alloc] init];
[shape setPath:rounded.CGPath];
self.layer.mask = shape;
}
@end
@implementation UILabel (XVAdd)
- (instancetype)initWithText:(NSString *)text textColor:(UIColor *)color textAlignment:(NSTextAlignment)alignment fontSize:(CGFloat)size {
UILabel *customLabel = [[UILabel alloc]init];
customLabel.text = text;
customLabel.textColor = color;
if (alignment) {
customLabel.textAlignment = alignment;
}
customLabel.font = [UIFont systemFontOfSize:size];
[customLabel sizeToFit];
return customLabel;
}
+ (void)changeLineSpaceForLabel:(UILabel *)label WithSpace:(float)space {
NSString *labelText = label.text;
NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:labelText];
NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
[paragraphStyle setLineSpacing:space];
[attributedString addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, [labelText length])];
label.attributedText = attributedString;
label.lineBreakMode = NSLineBreakByTruncatingTail;
[label sizeToFit];
}
+ (void)changeWordSpaceForLabel:(UILabel *)label WithSpace:(float)space {
NSString *labelText = label.text;
NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:labelText attributes:@{NSKernAttributeName:@(space)}];
NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
[attributedString addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, [labelText length])];
label.attributedText = attributedString;
[label sizeToFit];
}
+ (void)changeSpaceForLabel:(UILabel *)label withLineSpace:(float)lineSpace WordSpace:(float)wordSpace {
NSString *labelText = label.text;
NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:labelText attributes:@{NSKernAttributeName:@(wordSpace)}];
NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
[paragraphStyle setLineSpacing:lineSpace];
[attributedString addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, [labelText length])];
label.attributedText = attributedString;
[label sizeToFit];
}
@end
@implementation UIButton (XVAdd)
- (void)setHighlighted:(BOOL)highlighted {
}
#pragma mark - set Method
-(void)setHitEdgeInsets:(UIEdgeInsets)hitEdgeInsets{
NSValue *value = [NSValue value:&hitEdgeInsets withObjCType:@encode(UIEdgeInsets)];
objc_setAssociatedObject(self,kHitEdgeInsets, value, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}
-(void)setHitScale:(CGFloat)hitScale{
CGFloat width = self.bounds.size.width * hitScale;
CGFloat height = self.bounds.size.height * hitScale;
self.hitEdgeInsets = UIEdgeInsetsMake(-height, -width,-height, -width);
objc_setAssociatedObject(self, kHitScale, @(hitScale), OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}
-(void)setHitWidthScale:(CGFloat)hitWidthScale{
CGFloat width = self.bounds.size.width * hitWidthScale;
CGFloat height = self.bounds.size.height ;
self.hitEdgeInsets = UIEdgeInsetsMake(-height, -width,-height, -width);
objc_setAssociatedObject(self, kHitWidthScale, @(hitWidthScale), OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}
-(void)setHitHeightScale:(CGFloat)hitHeightScale{
CGFloat width = self.bounds.size.width;
CGFloat height = self.bounds.size.height * hitHeightScale ;
self.hitEdgeInsets = UIEdgeInsetsMake(-height, -width,-height, -width);
objc_setAssociatedObject(self, kHitHeightScale, @(hitHeightScale), OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}
#pragma mark - get Method
-(UIEdgeInsets)hitEdgeInsets{
NSValue *value = objc_getAssociatedObject(self, kHitEdgeInsets);
UIEdgeInsets edgeInsets;
[value getValue:&edgeInsets];
return value ? edgeInsets:UIEdgeInsetsZero;
}
-(CGFloat)hitScale{
return [objc_getAssociatedObject(self, kHitScale) floatValue];
}
-(CGFloat)hitWidthScale{
return [objc_getAssociatedObject(self, kHitWidthScale) floatValue];
}
-(CGFloat)hitHeightScale{
return [objc_getAssociatedObject(self, kHitHeightScale) floatValue];
}
#pragma mark - override super method
-(BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event{
//如果 button 边界值无变化 失效 隐藏 或者透明 直接返回
if(UIEdgeInsetsEqualToEdgeInsets(self.hitEdgeInsets, UIEdgeInsetsZero) || !self.enabled || self.hidden || self.alpha == 0 ) {
return [super pointInside:point withEvent:event];
}else{
CGRect relativeFrame = self.bounds;
CGRect hitFrame = UIEdgeInsetsInsetRect(relativeFrame, self.hitEdgeInsets);
return CGRectContainsPoint(hitFrame, point);
}
}
- (instancetype)initWithTitle:(NSString *)title fontSize:(CGFloat)size titleColor:(UIColor *)titleColor normalImageName:(NSString *)imageName selectedImgName:(NSString *)selectedImgName backgroundColor:(UIColor *)backgroundColor {
UIButton *customButton = [[UIButton alloc]init];
[customButton setTitle:title forState:UIControlStateNormal];
customButton.titleLabel.font = [UIFont systemFontOfSize:size];
[customButton setTitleColor:titleColor forState:UIControlStateNormal];
if (imageName) {
[customButton setImage:[UIImage imageNamed:imageName] forState:UIControlStateNormal];
}
if (selectedImgName) {
[customButton setImage:[UIImage imageNamed:selectedImgName] forState:UIControlStateSelected];
}
if (backgroundColor) {
customButton.backgroundColor = backgroundColor;
}
return customButton;
}
- (instancetype)initWithTitle:(NSString *)title fontSize:(CGFloat)size normalTitleColor:(UIColor *)normalTitleColor selectTitleColor:(UIColor *)selectTitleColor normalImgColor:(UIColor *)normalImgColor selectedImgColor:(UIColor *)selectedImgColor {
UIButton *customButton = [UIButton buttonWithType:UIButtonTypeCustom];
[customButton setTitle:title forState:UIControlStateNormal];
customButton.titleLabel.font = [UIFont systemFontOfSize:size];
[customButton setTitleColor:normalTitleColor forState:UIControlStateNormal];
[customButton setTitleColor:selectTitleColor forState:UIControlStateSelected];
if (normalImgColor) {
[customButton setBackgroundImage:[UIImage imageWithColor:normalImgColor] forState:UIControlStateNormal];
}
if (selectedImgColor) {
[customButton setBackgroundImage:[UIImage imageWithColor:selectedImgColor] forState:UIControlStateSelected];
}
return customButton;
}
- (instancetype)initWithTitle:(NSString *)title fontSize:(CGFloat)size titleColor:(UIColor *)titleColor bgColor:(UIColor *)bgColor {
UIButton *customButton = [UIButton buttonWithType:UIButtonTypeCustom];
[customButton setTitle:title forState:UIControlStateNormal];
customButton.titleLabel.font = [UIFont systemFontOfSize:size];
[customButton setTitleColor:titleColor forState:UIControlStateNormal];
if (bgColor) {
[customButton setBackgroundColor:bgColor];
}
return customButton;
}
- (instancetype)initWithNormalImageName:(NSString *)imageName selectedImgName:(NSString *)selectedImgName {
UIButton *customButton = [[UIButton alloc]init];
if (imageName) {
[customButton setImage:[UIImage imageNamed:imageName] forState:UIControlStateNormal];
}
if (selectedImgName) {
[customButton setImage:[UIImage imageNamed:selectedImgName] forState:UIControlStateSelected];
}
return customButton;
}
- (void)setForceRightToLeft:(CGFloat)spacing forState:(UIControlState)state {
if ([[UIDevice currentDevice].systemVersion floatValue] < 9.0) {
NSString *title = [self titleForState:state];
UIImage *image = [self imageForState:state];
if (title && image) {
[self setTitleEdgeInsets:UIEdgeInsetsMake(0, -image.size.width - spacing / 2, 0, image.size.width)];
CGSize labelSize = [title sizeWithAttributes:@{NSFontAttributeName:self.titleLabel.font}];
[self setImageEdgeInsets:UIEdgeInsetsMake(0, labelSize.width, 0, -labelSize.width - spacing / 2)];
}
} else {
self.semanticContentAttribute = UISemanticContentAttributeForceRightToLeft;
[self setTitleEdgeInsets:UIEdgeInsetsMake(0, -spacing / 2, 0, 0)];
[self setImageEdgeInsets:UIEdgeInsetsMake(0, 0, 0, -spacing / 2)];
}
}
@end
@implementation UIImageView (XVAdd)
- (instancetype)initWithImageName:(NSString *)imageNamed {
UIImageView *customImageView = [[UIImageView alloc]init];
customImageView.image = [UIImage imageNamed:imageNamed];
return customImageView;
}
@end
......@@ -7,27 +7,298 @@
//
#import "XVLoginViewController.h"
#import "XVInputFieldView.h"
@interface XVLoginViewController ()
@property (nonatomic, strong) UIView *containerView;
@property (nonatomic, strong) UILabel *titleLabel;
@property (nonatomic, strong) UIButton *changeLoginButton;
@property (nonatomic, strong) UIButton *forgetButton;
@property (nonatomic, strong) UIButton *registerButton;
@property (nonatomic, strong) UIButton *loginButton;
@property (nonatomic, strong) YYLabel *protocolLabel;
// 手机号登录
@property (nonatomic, strong) XVInputFieldView *phoneView;
@property (nonatomic, strong) XVInputFieldView *passwordView;
// 验证码登录
@property (nonatomic, strong) XVInputFieldView *phoneCodeView;
@property (nonatomic, strong) XVInputFieldView *smsCodeView;
@end
@implementation XVLoginViewController
- (void)viewDidLoad {
[super viewDidLoad];
[self wr_setNavBarBarTintColor:COLOR_THEMEGRENN];
self.view.backgroundColor = COLOR_THEMEGRENN;
[self setupUI];
}
- (void)setupUI {
[self.view addSubview:self.containerView];
[self.containerView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(self.view).mas_offset(120*heightScale);
make.left.right.bottom.mas_equalTo(self.view);
}];
[self.view layoutIfNeeded];
[self.containerView addRoundedCorners:UIRectCornerTopLeft | UIRectCornerTopRight withRadii:CGSizeMake(50, 50)];
[self.containerView addSubview:self.titleLabel];
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(self.containerView).mas_offset(37);
make.top.mas_equalTo(self.containerView).mas_offset(108*heightScale);
}];
[self.containerView addSubview:self.changeLoginButton];
[self.changeLoginButton sizeToFit];
[self.changeLoginButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.mas_equalTo(self.containerView).mas_offset(-31);
make.centerY.mas_equalTo(self.titleLabel);
}];
[self.containerView addSubview:self.phoneView];
[self.phoneView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(self.titleLabel.mas_bottom).mas_offset(58*heightScale);
make.left.mas_equalTo(self.containerView).mas_offset(30);
make.right.mas_equalTo(self.containerView).mas_offset(-30);
make.height.mas_equalTo(40);
}];
[self.containerView addSubview:self.passwordView];
[self.passwordView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(self.phoneView.mas_bottom).mas_offset(31*heightScale);
make.left.mas_equalTo(self.containerView).mas_offset(30);
make.right.mas_equalTo(self.containerView).mas_offset(-30);
make.height.mas_equalTo(40);
}];
[self.containerView addSubview:self.phoneCodeView];
self.phoneCodeView.hidden = YES;
[self.phoneCodeView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(self.titleLabel.mas_bottom).mas_offset(58*heightScale);
make.left.mas_equalTo(self.containerView).mas_offset(30);
make.right.mas_equalTo(self.containerView).mas_offset(-30);
make.height.mas_equalTo(40);
}];
[self.containerView addSubview:self.smsCodeView];
self.smsCodeView.hidden = YES;
[self.smsCodeView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(self.phoneCodeView.mas_bottom).mas_offset(31*heightScale);
make.left.mas_equalTo(self.containerView).mas_offset(30);
make.right.mas_equalTo(self.containerView).mas_offset(-30);
make.height.mas_equalTo(40);
}];
[self.containerView addSubview:self.forgetButton];
[self.forgetButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.mas_equalTo(self.containerView).mas_offset(-31);
make.top.mas_equalTo(self.passwordView.mas_bottom).mas_offset(17);
}];
[self.containerView addSubview:self.protocolLabel];
[self.protocolLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.bottom.mas_equalTo(self.containerView.mas_safeAreaLayoutGuideBottom).mas_offset(-55*widthScale);
make.left.right.mas_equalTo(self.containerView);
}];
[self.containerView addSubview:self.loginButton];
[self.loginButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(self.containerView).mas_offset(66);
make.right.mas_equalTo(self.containerView).mas_offset(-66);
make.height.mas_equalTo(44);
make.bottom.mas_equalTo(self.protocolLabel.mas_top).mas_offset(-72*heightScale);
}];
kViewBorderRadius(self.loginButton, 10, 0, [UIColor clearColor]);
[self.containerView addSubview:self.registerButton];
[self.registerButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.mas_equalTo(self.containerView);
make.height.mas_equalTo(22);
make.bottom.mas_equalTo(self.loginButton.mas_top).mas_offset(-17);
}];
[self.registerButton sizeToFit];
}
- (void)agreeClick:(UIButton *)button {
button.selected = !button.selected;
}
- (UIView *)containerView {
if(_containerView == nil) {
_containerView = [[UIView alloc]init];
_containerView.backgroundColor = [UIColor whiteColor];
}
return _containerView;
}
- (UILabel *)titleLabel {
if(_titleLabel == nil) {
_titleLabel = [[UILabel alloc]initWithText:@"登录骑手账号" textColor:FONT_1_COLOR textAlignment:NSTextAlignmentLeft fontSize:24];
}
return _titleLabel;
}
- (UIButton *)changeLoginButton {
if(_changeLoginButton == nil) {
_changeLoginButton = [[UIButton alloc]initWithTitle:@"验证码登录" fontSize:14 titleColor:BLUE_COLOR normalImageName:@"right" selectedImgName:@"right" backgroundColor:[UIColor whiteColor]];
[_changeLoginButton setTitle:@"密码登录" forState:UIControlStateSelected];
[_changeLoginButton setForceRightToLeft:0 forState:UIControlStateNormal];
WS(weakSelf);
[_changeLoginButton addBlockForControlEvents:UIControlEventTouchUpInside block:^(UIButton *sender) {
weakSelf.changeLoginButton.selected = !weakSelf.changeLoginButton.selected;
weakSelf.phoneView.hidden = !weakSelf.phoneView.hidden;
weakSelf.passwordView.hidden = !weakSelf.passwordView.hidden;
weakSelf.phoneCodeView.hidden = !weakSelf.phoneCodeView.hidden;
weakSelf.smsCodeView.hidden = !weakSelf.smsCodeView.hidden;
}];
}
return _changeLoginButton;
}
/*
#pragma mark - Navigation
- (XVInputFieldView *)phoneView {
if(_phoneView == nil) {
_phoneView = [[XVInputFieldView alloc]initWithType:InputTypeText placeholder:@"请输入手机号"];
}
return _phoneView;
}
- (XVInputFieldView *)passwordView {
if(_passwordView == nil) {
_passwordView = [[XVInputFieldView alloc]initWithType:InputTypePassword placeholder:@"请输入登录密码"];
}
return _passwordView;
}
- (XVInputFieldView *)phoneCodeView {
if(_phoneCodeView == nil) {
_phoneCodeView = [[XVInputFieldView alloc]initWithType:InputTypeSmsCode placeholder:@"请输入手机号"];
}
return _phoneCodeView;
}
- (XVInputFieldView *)smsCodeView {
if(_smsCodeView == nil) {
_smsCodeView = [[XVInputFieldView alloc]initWithType:InputTypeNumber placeholder:@"请输入验证码"];
}
return _smsCodeView;
}
- (UIButton *)forgetButton {
if(_forgetButton == nil) {
_forgetButton = [[UIButton alloc]initWithTitle:@"忘记密码" fontSize:14 titleColor:BLUE_COLOR normalImageName:@"right" selectedImgName:@"right" backgroundColor:[UIColor whiteColor]];
[_forgetButton setForceRightToLeft:0 forState:UIControlStateNormal];
}
return _forgetButton;
}
- (UIButton *)registerButton {
if(_registerButton == nil) {
_registerButton = [[UIButton alloc]initWithTitle:@"注册账号" fontSize:14 titleColor:kHexRGB(0x3D3B4F) bgColor:[UIColor whiteColor]];
}
return _registerButton;
}
- (UIButton *)loginButton {
if(_loginButton == nil) {
_loginButton = [[UIButton alloc]initWithTitle:@"登录" fontSize:16 titleColor:[UIColor whiteColor] bgColor:COLOR_THEMEGRENN];
}
return _loginButton;
}
- (YYLabel *)protocolLabel {
if(_protocolLabel == nil) {
_protocolLabel = [[YYLabel alloc]init];
NSMutableAttributedString *text = [NSMutableAttributedString new];
UIFont *font = [UIFont systemFontOfSize:12];
UIColor *color = [UIColor colorWithHexString:@"#737272"];
// UIView attachment
UIButton *selectButton = [[UIButton alloc]init];
[selectButton setImage:IMG(@"order_check box") forState:UIControlStateNormal];
[selectButton setImage:IMG(@"order_checkSelect") forState:UIControlStateSelected];
[selectButton addTarget:self action:@selector(agreeClick:) forControlEvents:UIControlEventTouchUpInside];
[selectButton sizeToFit];
selectButton.hitEdgeInsets = UIEdgeInsetsMake(-40, -40, -40, -40);
NSMutableAttributedString *attachment = [NSMutableAttributedString attachmentStringWithContent:selectButton contentMode:UIViewContentModeBottom attachmentSize:selectButton.size alignToFont:font alignment:YYTextVerticalAlignmentCenter];
[text appendAttributedString: attachment];
NSMutableAttributedString *str1 = [[NSMutableAttributedString alloc] initWithString:@" 我已阅读并同意"];
str1.font = font;
str1.color = color;
[text appendAttributedString:str1];
NSMutableAttributedString *str2 = [[NSMutableAttributedString alloc] initWithString:@"《快服务服务者合作协议》"];
str2.font = font;
str2.color = BLUE_COLOR;
YYTextHighlight *highlight = [YYTextHighlight new];
highlight.tapAction = ^(UIView *containerView, NSAttributedString *text, NSRange range, CGRect rect) {
};
[str2 setTextHighlight:highlight range:str2.rangeOfAll];
[text appendAttributedString:str2];
NSMutableAttributedString *str3 = [[NSMutableAttributedString alloc] initWithString:@"及"];
str3.font = font;
str3.color = color;
[text appendAttributedString:str3];
NSMutableAttributedString *str4 = [[NSMutableAttributedString alloc] initWithString:@"《隐私协议》"];
str4.font = font;
str4.color = BLUE_COLOR;
// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
YYTextHighlight *highlight1 = [YYTextHighlight new];
highlight1.tapAction = ^(UIView *containerView, NSAttributedString *text, NSRange range, CGRect rect) {
};
[str4 setTextHighlight:highlight1 range:str4.rangeOfAll];
[text appendAttributedString:str4];
_protocolLabel.attributedText = text;
_protocolLabel.textAlignment = NSTextAlignmentCenter;
}
return _protocolLabel;
}
*/
@end
//
// XVInputFieldView.h
// fastservice
//
// Created by xuning on 2/3/24.
// Copyright © 2024 FastService. All rights reserved.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
typedef enum : NSUInteger {
InputTypeNumber,
InputTypeText,
InputTypePassword,
InputTypeCode,
InputTypeSmsCode,
} InputType;
@interface XVInputFieldView : UIView
@property (nonatomic, strong) UILabel *titleLabel;
@property (nonatomic, strong) UITextField *textField;
@property (nonatomic, strong) UIButton *eyesButton;
@property (nonatomic, strong) UIButton *smsCodeButton;
@property (nonatomic,copy) void(^textEditingChanged)(NSString *obj);
/// 创建
/// @param type 类型
/// @param placeholder placeholder description
- (instancetype)initWithType:(InputType)type placeholder:(NSString *)placeholder;
@end
NS_ASSUME_NONNULL_END
//
// XVInputFieldView.m
// fastservice
//
// Created by xuning on 2/3/24.
// Copyright © 2024 FastService. All rights reserved.
//
#import "XVInputFieldView.h"
@interface XVInputFieldView()<UITextFieldDelegate>
@property (nonatomic, strong) UIView *lineView;
@property (nonatomic, strong) UIImageView *imageView;
@property (nonatomic,assign) InputType type;
@end
@implementation XVInputFieldView
- (instancetype)initWithType:(InputType)type placeholder:(NSString *)placeholder {
if (self = [super init]) {
self.type = type;
self.textField.placeholder = placeholder;
[self setupUI];
}
return self;
}
- (void)setupUI {
self.backgroundColor = [UIColor whiteColor];
[self addSubview:self.textField];
[self.textField mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerY.mas_equalTo(self);
make.left.mas_equalTo(self).mas_offset(0);
make.right.mas_equalTo(self).mas_offset(0);
make.width.mas_lessThanOrEqualTo(SCREEN_WIDTH-60);
make.height.mas_equalTo(44);
}];
[self addSubview:self.lineView];
[self.lineView mas_makeConstraints:^(MASConstraintMaker *make) {
make.bottom.mas_equalTo(self);
make.height.mas_equalTo(0.5);
make.left.mas_equalTo(self).mas_offset(0);
make.right.mas_equalTo(self).mas_offset(0);
}];
if(self.type == InputTypePassword) {
self.textField.secureTextEntry = YES;
[self addSubview:self.eyesButton];
[self.eyesButton sizeToFit];
[self.eyesButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.mas_equalTo(self).mas_offset(-7);
make.centerY.mas_equalTo(self.textField);
}];
}
if(self.type == InputTypeSmsCode) {
[self addSubview:self.smsCodeButton];
[self.smsCodeButton sizeToFit];
[self.smsCodeButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.mas_equalTo(self).mas_offset(-7);
make.centerY.mas_equalTo(self.textField);
make.height.mas_equalTo(28);
make.width.mas_equalTo(self.smsCodeButton.width + 10);
}];
kViewBorderRadius(self.smsCodeButton, 4, 0, [UIColor clearColor]);
}
if(self.type == InputTypeNumber) {
self.textField.keyboardType = UIKeyboardTypeNumberPad;
}
}
#pragma mark - UITextFieldDelegate
- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField {
[textField addTarget:self action:@selector(handlerTextFieldEndEdit:) forControlEvents:UIControlEventEditingChanged];
return YES; // 当前 textField 可以编辑
}
- (void)handlerTextFieldEndEdit:(UITextField *)textField {
if (self.textEditingChanged) {
self.textEditingChanged(textField.text);
}
}
- (UITextField *)textField {
if (_textField == nil) {
_textField = [[UITextField alloc]init];
[_textField setValue: kHexRGB(0x737272) forKeyPath:@"placeholderLabel.textColor"];
[_textField setValue:[UIFont systemFontOfSize:14] forKeyPath:@"placeholderLabel.font"];
_textField.font = [UIFont systemFontOfSize:14.0f];
_textField.textColor = [UIColor blackColor];
_textField.delegate = self;
}
return _textField;
}
- (UIView *)lineView {
if (_lineView == nil) {
_lineView = [[UIView alloc]init];
_lineView.backgroundColor = EF_3_COLOR;
}
return _lineView;
}
- (UIButton *)eyesButton {
if(_eyesButton == nil) {
_eyesButton = [[UIButton alloc]initWithNormalImageName:@"closeeyes" selectedImgName:@"openeyes"];
_eyesButton.hitEdgeInsets = UIEdgeInsetsMake(-10, -10, -10, -10);
WS(weakSelf);
[_eyesButton addBlockForControlEvents:UIControlEventTouchUpInside block:^(UIButton *sender) {
sender.selected = !sender.selected;
weakSelf.textField.secureTextEntry = !weakSelf.textField.secureTextEntry;
}];
}
return _eyesButton;
}
- (UIButton *)smsCodeButton {
if(_smsCodeButton == nil) {
_smsCodeButton = [[UIButton alloc]initWithTitle:@"获取验证码" fontSize:14 titleColor:[UIColor whiteColor] bgColor:BB_3_COLOR];
}
return _smsCodeButton;
}
- (UIImageView *)imageView {
if (_imageView == nil) {
_imageView = [[UIImageView alloc]init];
}
return _imageView;
}
@end
......@@ -22,6 +22,9 @@
#import "UINavigation+SXFixSpace.h"
#import "UIBarButtonItem+SXCreate.h"
#import "UIScrollView+XVAdd.h"
#import "UIView+XVAdd.h"
#import "NSString+XVAdd.h"
#endif
......@@ -38,6 +41,27 @@
#define kRandomColor KRGB(arc4random_uniform(256), arc4random_uniform(256), arc4random_uniform(256))
#define COLOR_THEMEGRENN [UIColor colorWithHexString:@"#4EB97B"]
#define BLUE_COLOR [UIColor colorWithHexString:@"#4290E5"]
#define YELLOW_COLOR [UIColor colorWithHexString:@"#edb10f"]
#define PURPLE_COLOR [UIColor colorWithHexString:@"#9E5BCA"]
#define RED_COLOR [UIColor colorWithHexString:@"#f25555"]
#define FONT_1_COLOR [UIColor colorWithHexString:@"#3D3B4F"]
#define FONT_2_COLOR [UIColor colorWithHexString:@"#707070"]
#define FONT_3_COLOR [UIColor colorWithHexString:@"#8a8a8a"]
#define FONT_4_COLOR [UIColor colorWithHexString:@"#bcbcbc"]
#define FONT_5_COLOR [UIColor colorWithHexString:@"#cfcfcf"]
#define FONT_6_COLOR [UIColor colorWithHexString:@"#7D7D7D"]
#define FONT_7_COLOR [UIColor colorWithHexString:@"#9B9B9B"]
#define FONT_8_COLOR [UIColor colorWithHexString:@"#666666"]
#define BG_1_COLOR [UIColor colorWithHexString:@"#e9e9e9"]
#define BG_2_COLOR [UIColor colorWithHexString:@"#f2f2f2"]
#define BG_3_COLOR [UIColor colorWithHexString:@"#fafafa"]
#define BB_3_COLOR [UIColor colorWithHexString:@"#BBBBBB"]
#define EF_3_COLOR [UIColor colorWithHexString:@"#efefef"]
#define B2_3_COLOR [UIColor colorWithHexString:@"#b2b2b2"]
#define DEFAULT_BACKGROUND_COLOR kHexRGB(0xf8f8f8)
#define kViewBorderRadius(View, Radius, Width, Color)\
......@@ -47,6 +71,7 @@
[View.layer setBorderColor:[Color CGColor]];
#define widthScale ([UIScreen mainScreen].bounds.size.width/375.0f)
#define heightScale ([UIScreen mainScreen].bounds.size.height/844.0f)
#define SCREEN_HEIGHT [[UIScreen mainScreen] bounds].size.height
#define SCREEN_WIDTH [[UIScreen mainScreen] bounds].size.width
//状态栏高度
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment