ZPCategory

directory


  1. Macro file
  2. NSString
  3. NSDate
  4. NSTimer
  5. NSDictionary
  6. UITextField
  7. UITextView
  8. UIButton
  9. UIImage
  10. UIViewController

Macro file

This file mainly has the following functions:

  1. Configuration of development environment and formal environment;
  2. Third party configuration integrated in the project;
  3. RGB color.
  4. Weak reference self;
  5. Screen width & height;
  6. Status bar& Tabbar&SafeArea value;
  7. Equipment judgment;

NSString

String width && height

1. Get the width of the string by font & height (no line height)

- (float)widthWithFont:(UIFont *)font height:(float)height;
Copy the code

2. Get the height of the string based on font & width (no line height)

- (float)heightWithFont:(UIFont *)font width:(float)width;
Copy the code

3. Get the height of the string based on font & width & line height;

- (float)heightWithFont:(UIFont *)font width:(float)width lineSpacing:(float)lineSpacing;
Copy the code

4. Get the string Size based on font & width & line height;

- (CGSize)sizeWithFont:(UIFont *)font width:(float)width lineSpacing:(float)lineSpacing;
Copy the code

String regular expression

1. Determine if it’s a cell phone number

- (BOOL)isValidateMobile;
Copy the code

2. Determine if it’s a landline

- (BOOL)isValidatePhone;
Copy the code

3. Determine if it’s a customer service number

- (BOOL)is400Phone;
Copy the code

4. Check if it’s an ID card

- (BOOL)isIdCard;
Copy the code

Data type amount judgment

1. Whether it is a positive integer

- (BOOL)isPositiveInteger;
Copy the code

2. Whether it is a floating point

- (BOOL)isFloat;
Copy the code

3. Check whether the input string consists of only letters and digits

- (BOOL)isNumberOrLetter;
Copy the code

4. Check whether the input string consists of only Chinese characters and English letters

- (BOOL)isChineseOrLetter;
Copy the code

5. Check whether the string is empty

- (BOOL)isBlankString;
Copy the code

NSString->NSAttributedString

1.NSString->NSAttributedString has a row height attribute

- (NSAttributedString *)toAttributeStringWithLineSpacing:(float)lineSpacing;
Copy the code

NSString computes the length of a byte

/** Calculates the length of the string in bytes * Chinese = 2 * English or number = 1 * expression = 4 @return NSUInteger */
- (NSUInteger)charactorNumber;

/** The length of the byte is calculated according to the encoding mode. @param Encoding @return NSUInteger */
- (NSUInteger)charactorNumberWithEncoding:(NSStringEncoding)encoding;

/** calulate the number of charactor. 1 Chinese(not including Chinese mark) = 2 1 other charactor = 1 @return NSUInteger * /
- (NSUInteger)charactorNumberForChineseSpecial;
Copy the code

This is the LXKit I collected from a guy at Github and I want to know more about it by clicking on it.

String encryption

1.MD5

- (NSString *)md5;
Copy the code

2.SHA1

- (NSString *)SHA1;
Copy the code

String filtering

1. Remove Spaces and carriage return at both ends

- (NSString *)trim;
Copy the code

2. Remove only Spaces at both ends

- (NSString *)trimOnlyWhitespace;
Copy the code

3. Remove the HTML format

+ (NSString *)filterHtml:(NSString *)html;
Copy the code

Returns the image by its name

1. Return the image according to the image name

- (UIImage *)toImage;
Copy the code

NSDate

1.NSDate -> NSString

- (NSString *)formatString:(NSString *)dateFormat;
Copy the code

2. Construct NSDate based on Unix timestamp

+ (NSDate *)dateWithUnixTime:(double)unixtime;
Copy the code

3. Change the time to 0 second mode

+ (NSDate *)changeDateToZeroMinutDate:(NSDate *)date;
Copy the code

4. Get the first and last days of the specified month

+ (NSArray *)getFirstAndLastDayOfThisMonthWithNsDate:(NSDate *)date;
Copy the code

NSTimer

1. Put on a timer in block mode

+ (NSTimer *)scheduledTimerWithTimeInterval:(NSTimeInterval)timeInterval block:(void(^) (void))block repeat:(BOOL)repeat;
Copy the code

NSDictionary

Get of the data type

1. Set a BOOL

- (BOOL)boolForKey:(NSString *)key;
Copy the code

2. Set an NSInteger value

- (NSInteger)integerForKey:(NSString *)key;
Copy the code

3. Set an int value

- (int)intForKey:(NSString *)key;
Copy the code

4. Set a double value

- (double)doubleForKey:(NSString *)key;
Copy the code

Set a float value

- (float)floatForKey:(NSString *)key;
Copy the code

6. Set a long long value

- (long long)longLongForKey:(NSString *)key;
Copy the code

7. Set an unsigned long long value

- (unsigned long long)unsignedLongLongForKey:(NSString *)key;
Copy the code

8. Set an NSString value

- (NSString *)stringForKey:(NSString *)key;
Copy the code

9. Set an NSArray value

- (NSArray *)arrayForKey:(NSString *)key;
Copy the code

10. If value is empty, the key is not set

- (void)safeValue:(id)value forKey:(NSString *)key;
Copy the code

UITextField

Maximum length and only numbers can be entered for attributes added

/** Maximum length */
@property (nonatomic.assign) NSInteger maxLength;

/** Whether only numbers can be entered */
@property (nonatomic.assign) BOOL canOnlyInputNumber;
Copy the code

LeftView

1. Set leftView to the image

/** * set leftview to image ** @param imageName imageName */
- (void)setLeftViewWithImageName:(NSString *)imageName;
Copy the code

2. Set leftView to text

/** * set leftView to text ** /
- (void)setLeftViewWithText:(NSString *)text;
Copy the code

3. Set leftView to text

/** * Set leftView to text ** @param text * @param minWidth minimum width */
- (void)setLeftViewWithText:(NSString *)text minWidth:(CGFloat)minWidth;
Copy the code

4. Set leftView to text

/** * set leftView to text ** @param text * @param minWidth * @param color placeholder text color */
- (void)setLeftViewWithText:(NSString *)text minWidth:(CGFloat)minWidth color:(UIColor *)color;
Copy the code

RightView

1. Set the rightView to text

/** * set rightView to text ** @param text text */
- (void)setRightViewWithText:(NSString *)text;
Copy the code

2. Set rightView to image

/** * set rightView to image ** @param imageName imageName */
- (void)setRightViewWithImageName:(NSString *)imageName;
Copy the code

3. Set rightView to Button

/** * set rightView to button ** @param imageName imageName */
- (void)setRightViewButtonWithImageName:(NSString *)imageName taget:(id)taget selector:(SEL)selector;
Copy the code

Padding

1. Set the left inner margin of the UITextField

/** * Set the left inner margin of the UITextField ** @param padding distance */
- (void)setPaddingLeftSpace:(float)padding;
Copy the code

2. Set the inside margin of the UITextField

/** * Set the right margin of the UITextField ** @param padding distance */
- (void)setPaddingRightSpace:(float)padding;
Copy the code

The UI display

1. Set the bottom border

/** * Sets the bottom border ** @param lineColor border color */
- (void)setBottomBorderLineWithColor:(UIColor *)lineColor;
Copy the code

2. Set the color to the placeholder

/** * placeholder color ** /
- (void)setPlaceholderColor:(UIColor *)color;
Copy the code

3. Set the underline out of the left side of the text

/** * sets the underline out of the left side of the text */
- (void)setLeftViewWithText:(NSString *)text minWidth:(CGFloat)minWidth withOutTextBottomLineColor:(UIColor *)color;
Copy the code

UITextView

Added placeHolder & placeHolderFont properties

@property (nonatomic.copy) NSString *placeHolder;

@property (nonatomic.strong) UIFont *placeHolderFont;
Copy the code

UButton

Click to change mode to Block mode

/** UIButton+Block ** @param controlEvent Touch event * @param action method */
- (void)handleControlEvent:(UIControlEvents)controlEvent withBlock:(ActionBlock)action;
Copy the code

UIImage

Returns the primary color of the photo

/** Return the main color of the photo @param image @return the color value */
+ (UIColor*)mostColor:(UIImage *)image;
Copy the code

UIViewController

NavigationBar

1. Set the left Navigationbar to “Return” (use backBarButtonItem)

/** * Set the left Navigationbar to "return" (using backBarButtonItem) */
- (void)setLeftNavigationBarToBack;
Copy the code

2. Set the left Navigationbar to “Back” (using leftBarButton)

/** * Set the left Navigationbar to "return" (using leftBarButton) ** @param block The block code that executes when clicked */
- (void)setLeftNavigationBarToBackWithBlock:(void(^) (void))block;
Copy the code

3. Add a confirmation dialog to the left back Navigationbar

/** * Added a confirmation prompt for the left back Navigationbar */
- (void)setLeftNavigationBarToBackWithConfirmDialog;
Copy the code

4. Set NavigationBar (text)

/** * Set NavigationBar (text) ** @param position * @param text * @param block click to execute the code */
- (void)setNavigationBar:(NavigationBarPosition)position withText:(NSString *)text touched:(void(^) (void))block;
Copy the code

5. Set NavigationBar (image)

/** * set NavigationBar (image) ** @param position * @param imageName imageName * @param block code executed after click */
- (void)setNavigationBar:(NavigationBarPosition)position withImageName:(NSString *)imageName touched:(void(^) (void))block;
Copy the code

6. Set NavigationBar (image)

/** * set NavigationBar (image) ** @param position * @param imageName imageName * @param block code executed after click */
- (void)setNavigationBar:(NavigationBarPosition)position withImageName:(NSString *)imageName spacing:(NSInteger)spacing touched:(void(^) (void))block;
Copy the code

7. Set NavigationBar (text)

/** * Set NavigationBar (text) ** @param position * @param text * @param color text * @param block code executed after click */
- (void)setNavigationBar:(NavigationBarPosition)position withText:(NSString *)text withColor:(UIColor *)color touched:(void(^) (void))block;
Copy the code

8. Set NavigationBar (text)

/** * Set NavigationBar (text) ** @param position * @param text * @param color text * @param font * @param block Click to execute the code */
- (void)setNavigationBar:(NavigationBarPosition)position withText:(NSString *)text withColor:(UIColor *)color withFont:(UIFont *)font touched:(void(^) (void))block;
Copy the code

9. Set NavigationBar to hide or show

/** * Set NavigationBar to hide or show ** @param position * @param hidden YES: hide NO: show */
- (void)hiddenNavigationBar:(NavigationBarPosition)position hidden:(BOOL)hidden;
Copy the code

10. Jump to the specified ViewController

/** * jumps to the specified ViewController ** @param viewControllerClass Controller type */
- (void)popToViewController:(Class)viewControllerClass;
Copy the code

NavigationController is the last ViewController in the NavigationController

/** * NavigationController ** /
- (UIViewController *)previosViewController;
Copy the code

12. Remove the previous ViewController from the ViewController in the current NavigationController

/** * Remove the previous ViewController */ from the ViewController in the current NavigationController
- (void)removePreviosViewControllerInNavigationControllers;
Copy the code

13. When adding multiple buttons

When adding multiple button / * * * * * @ param position location * @ param array buttonImageNameAndButtonTypeArray * @ param * @ param target goal Selector Response method */

- (void)setNavigationBar:(NavigationBarPosition)position withImageNameAndButtonTypeArray:(NSArray *)array target:(id)target selectors:(SEL)selector;
Copy the code

14. Remove navigationbutton

/** * remove navigationButton ** @param position */
- (void)removeNavigationBarBar:(NavigationBarPosition)position;
Copy the code

StoryBoard

1. Initialize the ViewController from the storyboard

/** * initialize ViewController from storyboard ** @param storyBoardName Storyboard name * @param Identifier ViewController identifier ** @return ViewController instance */
+ (instancetype)viewControllerFromStoryBoard:(NSString *)storyBoardName withIdentifier:(NSString *)identifier;
Copy the code

portal

Github.com/cAibDe/ZPCa…