美文网首页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 代码块

    创建 Xcode 代码块快捷键可以提高代码输入速度。常用代码块如下: 将上面所需的代码块选中后,拖到 Xcode ...

  • xcode 常用代码块

    在Xcode10正式发布之后,喜欢使用代码块的小伙伴会发现,原先位于编辑器右下角的代码块标识被放到上面了,点击 {...

  • Xcode常用代码块

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

  • Xcode常用代码块

    Xcode的代码片段(Code Snippets)创建自定义的代码片段,当你重用这些代码片段时,会给你带来很大的方...

  • Xcode 常用代码块

    在Xcode10正式发布之后,原先位于编辑器右下角的代码块标识被放到右上角的状态栏里,点击 {}按钮之后会将所有的...

  • xcode 创建可以复用的代码块

    #######摘要: 我们可以常用的代码块创建为模板,方便代码的复用,提高编码效率。Xcode创建可复用的代码块 ...

  • 常用的Xcode 代码块

    不废话 一、常用代码块 1、strong: @property (nonatomic, strong) <#Cla...

  • Xcode 代码块 (show snippets library

    代码块:事先存储到某处通过关键字调用的代码,比如常用的if语句就是设定好的代码块。 最新Xcode代码块(Snip...

  • Xcode中OC常用代码块

    Xcode-Code-Mark Of OC 简介 本文列举了以下代码块 Mark Section Title Ma...

  • iOS Xcode自定义代码块以及迁移

    iOS Xcode自定义代码块以及迁移 iOS Xcode自定义代码块以及迁移

网友评论

    本文标题:Xcode常用代码块

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