美文网首页iOS
Xcode常用代码块

Xcode常用代码块

作者: CYC666 | 来源:发表于2016-12-12 19:49 被阅读22次

    代码块路径 (注意:如果你的xcode没有添加过代码块,那你是找不到这个文件夹的)

    ~/Library/Developer/Xcode/UserData/CodeSnippets

    UILabel *<#label#> = [[UILabel alloc] initWithFrame:CGRectMake(<#CGFloat x#>, <#CGFloat y#>, <#CGFloat width#>, <#CGFloat height#>)];

    <#label#>.font = [UIFont systemFontOfSize:<#(CGFloat)#>];

    <#label#>.textColor = [UIColor colorWithRed:<#(CGFloat)#> green:<#(CGFloat)#> blue:<#(CGFloat)#> alpha:<#(CGFloat)#>];

    <#label#>.text =@"<#text#>";

    <#label#>.textAlignment = <#NSTextAlignment#>;

    <#label#>.numberOfLines = <#CGFloat#>;

    [self.view addSubview:<#label#>];

    ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    UIButton *<#button#> = [UIButton buttonWithType:UIButtonTypeCustom];

    <#button#>.frame = CGRectMake(<#CGFloat x#>, <#CGFloat y#>, <#CGFloat width#>, <#CGFloat height#>);

    [<#button#> setTitle:<#(nullable NSString *)#> forState:UIControlStateNormal];

    [<#button#> addTarget:selfaction:@selector(<#selector#>) forControlEvents:UIControlEventTouchUpInside];

    [self.view addSubview:<#button#>];

    ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    UITextField *<#textField#> = [[UITextField alloc] initWithFrame:CGRectMake(<#CGFloat x#>, <#CGFloat y#>, <#CGFloat width#>, <#CGFloat height#>)];

    <#textField#>.borderStyle = <#UITextBorderStyle#>;

    <#textField#>.placeholder =@"<#NSString#>";

    <#textField#>.clearButtonMode = <#UITextFieldViewModeWhileEditing#>;

    <#textField#>.returnKeyType = <#UIReturnKeySend#>;

    [self.view addSubview:<#textField#>];

    ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    UIImageView *<#imageView#> = [[UIImageView alloc] initWithFrame:CGRectMake(<#CGFloat x#>, <#CGFloat y#>, <#CGFloat width#>, <#CGFloat height#>)];

    <#imageView#>.image = [UIImage imageNamed:<#(nonnull NSString *)#>];

    [self.view addSubview:<#imageView#>];

    ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    UIBarButtonItem *<#item#> = [[UIBarButtonItem alloc] initWithTitle:<#(nullable NSString *)#>

    style:UIBarButtonItemStylePlain

    target:self

    action:@selector(<#selector#>)];

    [self.navigationController.navigationItem setRightBarButtonItem:<#item#>];

    ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    UIAlertController *<#alert#> = [UIAlertController alertControllerWithTitle:<#(nullable NSString *)#>

    message:<#(nullable NSString *)#>

    preferredStyle:UIAlertControllerStyleActionSheet];

    UIAlertAction*sureAction = [UIAlertActionactionWithTitle:@"确定"

    style:UIAlertActionStyleDefault

    handler:^(UIAlertAction*_Nonnullaction) {

    <#code#>

    }];

    UIAlertAction*cancelAction = [UIAlertActionactionWithTitle:@"取消"

    style:UIAlertActionStyleDefault

    handler:nil];

    [<#alert#> addAction:sureAction];

    [<#alert#> addAction:cancelAction];

    ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    <#view#>.layer.cornerRadius = <#CGFloat#>;

    <#view#>.layer.borderWidth = <#CGFloat#>;

    <#view#>.layer.borderColor = [UIColor colorWithRed:<#(CGFloat)#>/255.0

    green:<#(CGFloat)#>/255.0

    blue:<#(CGFloat)#>/255.0

    alpha:1];

    相关文章

      网友评论

        本文标题:Xcode常用代码块

        本文链接:https://www.haomeiwen.com/subject/pyxvmttx.html