Leif160519的blog Leif160519的blog

——————

目录
xcode中获取xib或者storyboard中控件 的两种方式
/    

xcode中获取xib或者storyboard中控件 的两种方式

1. 通过IBOutlet(通过拖动的方式)

这里写图片描述

2. 通过控件指定的tag属性来获取该控件(通过代码获取Tag的值来获取)

这里写图片描述

UILable * myLable = (UILabel *)[self.view viewWithTag:12];
myLabel.text = @"IOS";

说明:如果事先通过拖动,声明了UILabel,那么,在.m中直接用self.myLabel.text = @"IOS"或者是_myLabel.text = @"IOS";就可以实现文字的显示,如果不通过这种方法的话,则需要新建一个UILabel,并且定位他得tag的值,进而用myLabel.text=@"IOS"的语法进行内容的显示


“The first 90% of the code accounts for the first 90% of the development time. The remaining 10% of the code accounts for the other 90% of the development time.” – Tom Cargill

标  题xcode中获取xib或者storyboard中控件 的两种方式
作  者Leif160519
出  处https://github.icu/articles/2019/08/23/1566542477963.html
关于博主:坐标南京,运维工程师,如有问题探讨可以直接下方留言。
声援博主:如果您觉得文章对您有帮助,可以评论、订阅、收藏。您的鼓励是博主的最大动力!