快捷组件指引

iOS之单独使用UISearchBar创建搜索框

https://www.jianshu.com/p/dd6f0a0b1781

1.实现代理UISearchBarDelegate

@interface SearchViewController ()<UISearchBarDelegate>

2.创建一个UISearchBar为属性

@property (nonatomic, strong) UISearchBar *searchBar;

3.进入页面后弹起键盘和离开页面前收起键盘

- (void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];
    if (!_searchBar.isFirstResponder) {
        [self.searchBar becomeFirstResponder];
    }
}
- (void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:animated];
    [self.searchBar resignFirstResponder];
}

4.具体实现

-(UISearchBar *)searchBar{

  **if** (!_searchBar) {





   //创建searchBar

 _searchBar = [[UISearchBar alloc] initWithFrame:CGRectMake(0, 0, 10,20)];

   //默认提示文字

   _searchBar.placeholder = @"搜索内容";

    //背景图片

  _searchBar.backgroundImage = [UIImage imageNamed:@"clearImage"];

   //代理

    _searchBar.delegate = **self**;

   //显示右侧取消按钮

   _searchBar.showsCancelButton = **YES**;

  //光标颜色

    _searchBar.tintColor = [UIColor blackColor];

 //  [_searchBar setBackgroundColor:[UIColor whiteColor]];

    [_searchBar.searchTextField setBackgroundColor:[UIColor whiteColor]];

   [**self**.navigationController.navigationBar addSubview:_searchBar];

   [_searchBar mas_makeConstraints:^(MASConstraintMaker *make){

     make.leading.mas_equalTo(**self**.navigationController.navigationBar).offset(60);

    make.trailing.mas_equalTo(**self**.navigationController.navigationBar).offset(-20);

     make.centerY.mas_equalTo(0);

    make.height.mas_equalTo(44);

    }];

  }

  return _searchBar;

}

-(UIButton *)searchBtn{
    if (!_searchBtn) {
        _searchBtn = [self.searchBar valueForKeyPath:@"cancelButton"];
        _searchBtn.enabled = YES;
        [_searchBtn setTitle:@"取消" forState:UIControlStateNormal];
        [_searchBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        [_searchBtn addTarget:self action:@selector(searchButtonClicked) forControlEvents:UIControlEventTouchUpInside];

    }
    return _searchBtn;


}

字体列表
  、苹方-简 常规体
  font-family: PingFangSC-Regular, sans-serif;
  苹方-简 极细体
  font-family: PingFangSC-Ultralight, sans-serif;
  苹方-简 细体
  font-family: PingFangSC-Light, sans-serif;
  苹方-简 纤细体
  font-family: PingFangSC-Thin, sans-serif;
  苹方-简 中黑体
  font-family: PingFangSC-Medium, sans-serif;
  苹方-简 中粗体
  font-family: PingFangSC-Semibold, sans-serif;
- (void)setBarButtonItem
{
    //隐藏导航栏上的返回按钮
    [self.navigationItem setHidesBackButton:YES];
    //用来放searchBar的View
    UIView *titleView = [[UIView alloc] initWithFrame:CGRectMake(5, 7, self.view.frame.size.width, 30)];
    //创建searchBar
    UISearchBar *searchBar = [[UISearchBar alloc] initWithFrame:CGRectMake(0, 0, CGRectGetWidth(titleView.frame) - 15, 30)];
    //默认提示文字
    searchBar.placeholder = @"搜索内容";
    //背景图片
    searchBar.backgroundImage = [UIImage imageNamed:@"clearImage"];
    //代理
    searchBar.delegate = self;
    //显示右侧取消按钮
    searchBar.showsCancelButton = YES;
    //光标颜色
    searchBar.tintColor = UIColorFromRGB(0x595959);
    //拿到searchBar的输入框
    UITextField *searchTextField = [searchBar valueForKey:@"_searchField"];
    //字体大小
    searchTextField.font = [UIFont systemFontOfSize:15];
    //输入框背景颜色
    searchTextField.backgroundColor = [UIColor colorWithRed:234/255.0 green:235/255.0 blue:237/255.0 alpha:1];
    //拿到取消按钮
    UIButton *cancleBtn = [searchBar valueForKey:@"cancelButton"];
    //设置按钮上的文字
    [cancleBtn setTitle:@"取消" forState:UIControlStateNormal];
    //设置按钮上文字的颜色
    [cancleBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [titleView addSubview:searchBar];
    self.searchBar = searchBar;
    self.navigationItem.titleView = titleView;
}

5.实现代理方法

#pragma mark - UISearchBarDelegate
- (BOOL)searchBarShouldBeginEditing:(UISearchBar *)searchBar{
    return YES;
}

- (void)searchBarTextDidBeginEditing:(UISearchBar *)searchBar {
    searchBar.showsCancelButton = YES;
}

- (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar
{
    NSLog(@"SearchButton");
}

- (void)searchBarCancelButtonClicked:(UISearchBar *)searchBar
{
    [self.searchBar resignFirstResponder];
    [self.navigationController popViewControllerAnimated:YES];
}

- (void)searchBarTextDidEndEditing:(UISearchBar *)searchBar
{
    searchBar.showsCancelButton = YES;
}

- (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText
{
    NSString *inputStr = searchText;
    [self.results removeAllObjects];
    for (ElderModel *model in self.dataArray) {
        if ([model.name.lowercaseString rangeOfString:inputStr.lowercaseString].location != NSNotFound) {
            [self.results addObject:model];
        }
    }
    [self.tableView reloadData];
}

代码

按钮

btn.titleLabel.font = [UIFont systemFontOfSize: 14.0];

btn.titleLabel.font = [UIFont fontWithName:@”PingFangSC-Regular” size: 14];

btn.contentHorizontalAlignment = UIControlContentHorizonAlignmentLeft

btn.contentEdgeInsets = UIEdgeInsetsMake(0,10, 0, 0);

[btn setTitleColor:[UIColor blackColor]forState:UIControlStateNormal];

Xib

按钮

设置圆角:Key Path:layer.cornerRadius Type:Number Value:8

设置边框宽度:Key Path:layer.borderWidth Type:Number Value:1

如果要设置边框的颜色:Key Path:layer.borderColor Type:Color Value值默认,此时边框颜色为黑色,若要改变Value的值,则边框消失

注意:在设置属性的时候,千万不要写错,我开始的时候是复制过来的,多了一个空格,结果就无法显示设置的效果

下面介绍如何设置边框颜色:

要想设置任意的边框颜色,首先要对CALayer添加category,然后在category中添加一个方法

具体步骤如下:

1.创建category

command+N创建新文件,选择iOS→Source→Objective-C File,然后File Type选择Category,Class选择CALayer,File为自定义文件名

2.在.m文件中添加方法

创建好文件后,在.m文件新增方法

- (void)setBorderColorWithUIColor:(UIColor *)color

{

self.borderColor = color.CGColor;

}

此时会报错,需要导入头文件

#import <UIKit/UIKit.h>

3.在xib中添加属性

在xib中设置边框颜色,添加属性Key Path:layer.borderColorWithUIColor Type:Color 此时Value可以任意选择

再次提醒:填写Key Path的时候一定要填写正确,即使多一个空格也不会显示对应的效果

自定义xib cell的 uitableview

//

// SPRDeviceViewController.m

// SafeProduction

//

// Created by 胡礼节 on 2020/10/14.

//

\#import "SPRDeviceViewController.h"

\#import "TextContentTableViewCell.h"

**static** NSString *CellIdentifier = @"cellId";

**@interface** SPRDeviceViewController ()<UITableViewDelegate,UITableViewDataSource>{

UITableView *tableView;

NSMutableArray *dataArray;

``

}

**@end**

**@implementation** SPRDeviceViewController

\- (**void**)viewDidLoad {

[**super** viewDidLoad];

dataArray = [[NSMutableArray alloc]initWithArray: @[@"1",@"2"]];

tableView = [[UITableView alloc]initWithFrame:**self**.view.frame style:UITableViewStylePlain];

[tableView registerNib:[UINib nibWithNibName:@"TextContentTableViewCell" bundle:**nil**] forCellReuseIdentifier:CellIdentifier];

tableView.delegate = **self**;

tableView.dataSource = **self**;

[**self**.view addSubview:tableView];

// Do any additional setup after loading the view.

}

/*

\#pragma mark - Navigation

// 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.

}

*/

\- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{

**return** Ratio(170);

}

\- (**nonnull** UITableViewCell *)tableView:(**nonnull** UITableView *)tableView cellForRowAtIndexPath:(**nonnull** NSIndexPath *)indexPath {

``

TextContentTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];

``

``

``

**return** cell;

}

\- (NSInteger)tableView:(**nonnull** UITableView *)tableView numberOfRowsInSection:(NSInteger)section {

**return** dataArray.count;

}

**@end**

通知

/注册通知//方法实现

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updatCardInfo:) name:updateCardInfoNotification object:nil];

//方法实现

-(void) updatCardInfo :(NSNotification*) notification

{

接收参数 = [notification object]; //通过这个获取到传递的对象

}

//发送通知

[[NSNotificationCenter defaultCenter] postNotificationName:updateCardInfoNotification object:参数];

2、不带参数

//注册通知

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(deviceDamage) name:VDBlueToothDamageNotification object:nil];

//方法实现

-(void)deviceDamage

{

}

//发送通知

[[NSNotificationCenter defaultCenter] postNotificationName:VDBlueToothDamageNotification object:nil];

网络

form表单

https://www.jianshu.com/p/ab4068abf847

NSDATE 时间

//方式三
NSDateFormatter *dateFmt2 = [[NSDateFormatter alloc]init];
dateFmt2.dateFormat = @"yyyy年MM年dd日 HH时mm分ss秒 aa";
NSString *dateStr2 = [dateFmt2 stringFromDate:date];
NSLog(@"方式三: %@",dateStr2); 

键盘

https://www.jianshu.com/p/532d12375e9a

动画

self.treeImgView.transform = CGAffineTransformIdentity;

CGRect oldFrame = self.treeImgView.frame;

[self.treeImgView layer].anchorPoint = CGPointMake(0.5f, 1.0f);

self.treeImgView.frame = oldFrame;

CASpringAnimation *ani = [CASpringAnimation animationWithKeyPath:@”transform.scale.y”];

ani.mass = 500.0;

ani.stiffness = 100000;

ani.damping = 3000.0;

ani.initialVelocity = 90.f;

ani.duration = ani.settlingDuration;

ani.toValue = [NSNumber numberWithFloat:1.01];

ani.removedOnCompletion = NO;

ani.fillMode = kCAFillModeForwards;

ani.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];

[self.treeImgView.layer addAnimation:ani forKey:@”springAni”];

//

CASpringAnimation *ani1 = [CASpringAnimation animationWithKeyPath:@”transform.scale.y”];

[ani1 setBeginTime:ani.settlingDuration / 3];

ani1.mass = 28.0;

ani1.stiffness = 5000;

ani1.damping = 120.0;

ani1.initialVelocity = 4.f;

ani1.duration = ani1.settlingDuration;

// ani.duration = ani.settlingDuration;

ani1.duration = ani1.settlingDuration;

// ani.fromValue = [NSValueTransformer CGAffineTransformMakeScale(1,1.1)];

ani1.toValue = [NSNumber numberWithFloat:1];

// ani.toValue = [NSValue valueWithCGRect:CGRectMake(50,150, 300, 250)];

ani1.removedOnCompletion = NO;

ani1.fillMode = kCAFillModeForwards;

ani1.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];

// [self.treeImgView.layer addAnimation:ani1 forKey:@”springAni”];

//

//

//

// CASpringAnimation *ani2 = [CASpringAnimation animationWithKeyPath:@”transform.scale.y”];

// [ani2 setBeginTime:ani1.settlingDuration / 2 + ani.settlingDuration / 2 ];

// ani2.mass = 8.0;

// ani2.stiffness = 2000;

// ani2.damping = 120.0;

// ani2.initialVelocity = 4.f;

// ani2.duration = 1;

//// ani.fromValue = [NSValueTransformer CGAffineTransformMakeScale(1,1.1)];

// ani2.toValue = [NSNumber numberWithFloat:1.05];

//// ani.toValue = [NSValue valueWithCGRect:CGRectMake(50,150, 300, 250)];

// ani2.removedOnCompletion = NO;

// ani2.fillMode = kCAFillModeForwards;

// ani2.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];

//

//

//

//

// CASpringAnimation *ani3 = [CASpringAnimation animationWithKeyPath:@”transform.scale.y”];

// [ani3 setBeginTime:ani1.settlingDuration / 2 + ani.settlingDuration / 2 + ani2.settlingDuration / 2];

// ani3.mass = 8.0;

// ani3.stiffness = 2000;

// ani3.damping = 120.0;

// ani3.initialVelocity = 4.f;

// ani3.duration = 1.0f;

//// ani.fromValue = [NSValueTransformer CGAffineTransformMakeScale(1,1.1)];

// ani3.toValue = [NSNumber numberWithFloat:1];

//// ani.toValue = [NSValue valueWithCGRect:CGRectMake(50,150, 300, 250)];

// ani3.removedOnCompletion = NO;

// ani3.fillMode = kCAFillModeForwards;

// ani3.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];

//

//

//

CAAnimationGroup *group = [CAAnimationGroup animation];

// 添加动画

group.animations = [NSArray arrayWithObjects:ani, nil];

//取消动画反弹

group.removedOnCompletion = NO;

//设置动画执行完成后保持最新的效果

// group.fillMode = kCAFillModeForwards;

float t = 0.0 ;

float tr1 = 1.2;

float tr2 = 1;

NSMutableArray *array = [NSMutableArray new];

for (int i = 0; i < 10; i ++) {

if (i % 2 == 0) {

​ CASpringAnimation *ani5 = [CASpringAnimation animationWithKeyPath:@”transform.scale.y”];

​ ani5.mass = 8.0;

​ ani5.stiffness = 2000;

​ ani5.damping = 120.0;

​ ani5.initialVelocity = 4.f;

​ ani5.duration = ani5.settlingDuration;

​ // ani.fromValue = [NSValueTransformer CGAffineTransformMakeScale(1,1.1)];

​ ani5.toValue = [NSNumber numberWithFloat:tr1];

​ // ani.toValue = [NSValue valueWithCGRect:CGRectMake(50,150, 300, 250)];

​ ani5.removedOnCompletion = NO;

​ ani5.fillMode = kCAFillModeForwards;

​ ani5.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];

​ tr1 -= 0.02;

// t += ani5.settlingDuration / 2;

​ t += ani5.settlingDuration ;

​ [ani5 setBeginTime:t];

// group.animations

​ [array addObject:ani5];

​ }else{

​ CASpringAnimation *ani5 = [CASpringAnimation animationWithKeyPath:@”transform.scale.y”];

​ ani5.mass = 8.0;

​ ani5.stiffness = 2000;

​ ani5.damping = 120.0;

​ ani5.initialVelocity = 4.f;

​ ani5.duration = ani5.settlingDuration;

​ // ani.fromValue = [NSValueTransformer CGAffineTransformMakeScale(1,1.1)];

​ ani5.toValue = [NSNumber numberWithFloat:1];

​ // ani.toValue = [NSValue valueWithCGRect:CGRectMake(50,150, 300, 250)];

​ ani5.removedOnCompletion = NO;

​ ani5.fillMode = kCAFillModeForwards;

​ ani5.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];

​ tr1 -= 0.02;

// t += ani5.settlingDuration / 2;

​ t += ani5.settlingDuration ;

​ [ani5 setBeginTime:t];

​ [array addObject:ani5];

​ }

}

// 动画选项设定

group.duration = ani.settlingDuration ;

group.repeatCount = 1;

// group.animations = array;

// [self.treeImgView.layer addAnimation:group forKey:@”springAni”];

//

// // CGPoint center = self.treeImgView.center;

// CGRect oldFrame = self.treeImgView.frame;

//

// [self.treeImgView layer].anchorPoint = CGPointMake(0.5f, 1.0f);

//

// self.treeImgView.frame = oldFrame;

// // self.treeImgView.transform = CGAffineTransformMakeScale(1, 1.05);

// self.treeImgView.transform = CGAffineTransformMakeScale(1, 0.99);

// [UIView animateWithDuration:1

// delay:0

// usingSpringWithDamping:0.25

// initialSpringVelocity:0

// options:UIViewAnimationOptionCurveLinear

// animations:^{

//

// self.treeImgView.transform = CGAffineTransformMakeScale(1, 1);

//

//

// } completion:^(BOOL finished) {

//

// if(finished)

// {

// // [UIView animateWithDuration:0.15 animations:^{

// self.treeImgView.transform = CGAffineTransformIdentity;

// // }];

//

// }

//

// }];

self.treeImgView.transform = CGAffineTransformIdentity;

CGRect oldFrame = self.treeImgView.frame;

[self.treeImgView layer].anchorPoint = CGPointMake(0.5f, 1.0f);

self.treeImgView.frame = oldFrame;

CASpringAnimation *ani = [CASpringAnimation animationWithKeyPath:@”transform.scale.y”];

ani.mass = 500.0;

ani.stiffness = 100000;

ani.damping = 3000.0;

ani.initialVelocity = 90.f;

ani.duration = ani.settlingDuration;

ani.toValue = [NSNumber numberWithFloat:1.01];

ani.removedOnCompletion = NO;

ani.fillMode = kCAFillModeForwards;

ani.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];

[self.treeImgView.layer addAnimation:ani forKey:@”springAni”];

collcetionView

https://www.jianshu.com/p/d0b034f59020

https://www.jianshu.com/p/f0eeef56f391

快捷键汇总

NSObject

  • pa - 定义一个 assign 的 property
  • par - 定义一个 assign, readonly 的 property
  • pc - 定义一个 copy 的 property
  • pcr - 定义一个 copy, readonly 的 property
  • ps - 定义一个 strong 的property
  • psr - 定义一个 strong, readonly 的property
  • pw - 定义一个 weak 的property
  • pwr - 定义一个 weak, readonly 的property
  • load_once - 创建一个带 dispatch_once+load 方法
  • propertySwizzleAssign - 用 swizzle 的方式定义一个 assign 的property
  • propertySwizzleCopy - 用 swizzle 的方式定义一个 copy 的property
  • propertySwizzleStrong - 用 swizzle 的方式定义一个 strong 的property
  • propertySwizzleWeak - 用 swizzle 的方式定义一个 weak 的property
  • sharedInstance - 为当前类创建一个实现单例功能的 sharedInstance 方法
  • exchangeImplementation - 重写当前类的 load 方法并在其中用 swizzle 替换方法实现
  • exchangeImplementation_QMUI - 用 QMUI 重写当前类的 load 方法并用 ExchangeImplementations() 函数替换方法的实现
  • exchangeMultipleImplementations_QMUI - 用 QMUI 重写当前类的 load 方法并用 ExchangeImplementations() 函数批量替换多个方法的实现
  • override_void_non_argv - 用 QMUI 的 OverrideImplementation() 重写指定 class 的某个无返回值、无参数的方法实现
  • override_void_single_argv - 用 QMUI 的 OverrideImplementation() 修改指定 class 的某个无返回值、带一个参数的方法实现
  • override_void_two_argvs - 用 QMUI 的 OverrideImplementation() 修改指定 class 的某个无返回值、带两个参数的方法实现
  • override_return_non_argv - 用 QMUI 的 OverrideImplementation() 修改指定 class 的某个带返回值、无参数的方法实现
  • override_return_single_argv - 用 QMUI 的 OverrideImplementation() 修改指定 class 的某个带返回值、带一个参数的方法实现
  • override_return_two_argvs - 用 QMUI 的 OverrideImplementation() 修改指定 class 的某个带返回值、带两个参数的方法实现
  • extend_void_non_argv - 用 QMUI 的 ExtendImplementationOfVoidMethodWithoutArguments() 修改指定 class 的某个无返回值、无参数的方法实现
  • extend_void_single_argv - 用 QMUI 的 ExtendImplementationOfVoidMethodWithSingleArgument() 修改指定 class 的某个无返回值、带一个参数的方法实现
  • extend_void_two_argvs - 用 QMUI 的 ExtendImplementationOfVoidMethodWithTwoArguments() 修改指定 class 的某个无返回值、带两个参数的方法实现
  • extend_return_non_argv - 用 QMUI 的 ExtendImplementationOfNonVoidMethodWithoutArguments() 修改指定 class 的某个带返回值、无参数的方法实现
  • extend_return_single_argv - 用 QMUI 的 ExtendImplementationOfNonVoidMethodWithSingleArgument()修改指定 class 的某个带返回值、带一个参数的方法实现
  • extend_return_two_argvs - 用 QMUI 的 ExtendImplementationOfNonVoidMethodWithTwoArguments() 修改指定 class 的某个带返回值、带两个参数的方法实现

Block

  • blockParameterInMethod - 声明一个用于 OC 方法参数的 block
  • blockParameterInFunction - 声明一个用于 C 函数参数的 block
  • blockproperty - 声明一个用于 property 的 block
  • blocktypedef - 用 typedef 定义一个 block
  • blockvar - 定义一个作为局部变量的 block

Method & Function

  • fnv - 定义一个返回值为 void 的方法
  • fnv: - 定义一个返回值为 void 且带参数的方法
  • fnblock - 定义一个返回值类型为 block 的方法
  • fnv_handleEvent - 定义一个用于 UIControl 事件回调的方法
  • fnv_longPress - 定义一个用于 UILongPressGestureRecognizer 的回调方法(你就不用每次都去拼写那个很长的手势名字了)
  • fnv_pan - 定义一个用于 UIPanGestureRecognizer 的回调方法
  • fnv_tap - 定义一个用于 UITapGestureRecognizer 的回调方法

UIView

  • setFrame - 为 UIView 设置 frame
  • setFrame_QMUI - QMUI 使用像素对齐的 CGRectFlatMake()UIView 设置 frame
  • setFrameX - QMUI 使用 CGRectSetX() 修改 UIViewframe.origin.x
  • setFrameY - QMUI 使用 CGRectSetY() 修改 UIViewframe.origin.y
  • setFrameXY - QMUI 使用 CGRectSetXY() 修改 UIViewframe.origin
  • sizeThatFits - 为当前 view 创建 sizeThatFits: 方法
  • layoutSubviews - 展开 layoutSubviews 方法
  • updateConstraints - 展开 updateConstraints 方法
  • getWidth - 展开 CGRectGetWidth()
  • getHeight - 展开 CGRectGetHeight()
  • getMinX - 展开 CGRectGetMinX()
  • getMinY - 展开 CGRectGetMinY()
  • addtarget - 调用 UIControl addTarget:action:forEvents: 方法
  • setImageForButton - 为 UIButton 设置图片
  • setTitleColorForButton - 为 UIButton 设置文字颜色
  • setTitleForButton - 为 UIButton 设置文字

UITableView

  • initWithStyle - 展开 initWithStyle: 方法
  • initWithStyleForCell - 展开 UITableViewCell initWithStyle:reuseIdentifier: 方法
  • tableViewDelegate - 展开常用的几个 UITableViewDelegate 方法
  • numberOfSectionsInTableView - 展开 numberOfSectionsInTableView:方法
  • numberOfRowsInSection - 展开 tableView:numberOfRowsInSection: 方法
  • cellForRowAtIndexPath - 展开 tableView:cellForRowAtIndexPath: 方法
  • heightForRowAtIndexPath - 展开 tableView:heightForRowAtIndexPath: 方法
  • didSelectRowAtIndexPath - 展开 tableView:didSelectRowAtIndexPath: 方法

UICollectionView

  • collectionViewDelegate - 展开常用的几个UICollectionViewDelegate 方法
  • numberOfSectionsInCollectionView - 展开 numberOfSectionsInCollectionView:
  • numberOfItemsInSection - 展开 collectionView:numberOfItemsInSection:
  • cellForItemAtIndexPath - 展开 collectionView:cellForItemAtIndexPath:
  • sizeForItemAtIndexPath - 展开 collectionView:layout:sizeForItemAtIndexPath: 方法
  • didSelectItemAtIndexPath - 展开 collectionView:didSelectItemAtIndexPath: 方法
  • didDeselectItemAtIndexPath - 展开 collectionView:didDeselectItemAtIndexPath: 方法

UIViewController

  • initWithNib - 展开 initWithNibName:bundle: 方法
  • didInitialize - 展开某些 QMUI 控件提供的 didInitialize 方法
  • didInitializeWithStyle - 展开 QMUICommonTableViewController 的 didInitializeWithStyle: 方法
  • loadView - 展开 loadView 方法
  • viewDidLoad - 展开 viewDidLoad 方法
  • viewWillAppear - 展开 viewWillAppear: 方法
  • viewDidAppear - 展开 viewDidAppear: 方法
  • viewWillDisappear - 展开 viewWillDisappear: 方法
  • viewDidDisappear - 展开 viewDidDisappear: 方法
  • viewDidLayoutSubviews - 展开 viewDidLayoutSubviews: 方法
  • updateViewConstraints - 展开 updateViewConstraints: 方法
  • addChildViewController - 在当前 UIViewController 里添加 childViewController
  • removeFromParentViewController - 将 childViewController 从当前的 UIViewController 里移除
  • initSubviews - QMUI 展开 initSubviews 方法
  • setupNavigationItems - QMUI 重写 QMUICommonViewController 里的 setupNavigationItems 方法
  • setupToolbarItems - QMUI 重写 QMUICommonViewController 里的 setupToolbarItems 方法

UIBarButtonItem

  • backItem - 用 QMUI 方法生成一个返回按钮
  • boldTitleItem - 用 QMUI 方法生成一个文字加粗的导航栏按钮
  • closeItem - 用 QMUI 方法生成一个导航栏上的关闭图标按钮
  • imageItem - 用 QMUI 方法生成一个导航栏上的图片按钮
  • titleItem - 用 QMUI 方法生成一个导航栏上的文字按钮

Other

  • pragma - 展开一个用于 Xcode 导航的 #pragma mark -
  • log - 展开 NSLog(@"xxx")
  • osif - 展开一个 @available(iOS xxx, *) 的 if 判断
  • externRefInH - 在 *.h 文件里声明一个 extern const 的指针
  • externRefInM - 在 *.m 文件里为一个 extern const 的指针赋值
  • externValueInH - 在 *.h 文件里声明一个 extern const 的值变量
  • externValueInM - 在 *.m 文件里为一个 extern const 的变量赋值
  • static reference - 定义一个 static 的指针
  • static - 定义一个 static 的值变量
  • __weakSelf - 定义一个 weakself 指针
  • __strongSelf - 将 weakSelf 指针改为 strongself 指针
  • logCallStackSymbols - 用 NSLog 打出当前的方法调用栈信息
  • timeConsuming - 展开一段用 CACurrentMediaTime() 来计算方法耗时的代码

   转载规则


《快捷组件指引》 采用 知识共享署名 4.0 国际许可协议 进行许可。
 上一篇
QMUI-快捷代码片段指南.md QMUI-快捷代码片段指南.md
快捷键汇总NSObject pa - 定义一个 assign 的 property par - 定义一个 assign, readonly 的 property pc - 定义一个 copy 的 property pcr - 定义一个 c
2020-11-12
下一篇 
fastlane使用说明书 fastlane使用说明书
2020-04-21 更新大部分细节都类似,有一个绕过两步验证的更新一下, 其实你开一个有上传权限的子账号 就可以绕过两步验证,子账号没有强制要求两步验证。 05-15新版本内容变化,大致没太多改动,一些新细节整理一下1、用swift初始化
2020-10-12
  目录