相关疑难解决方法(0)

如何通过标签从UIView获取某个子视图

我是Objective-C的菜鸟,我有一个问题.

我有一个UILabel对象,我用这段代码添加到一个UIView:

UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0,10,self.view.frame.size.width-15-70, 30)];
label.tag = 1;
label.font = [PublicObject fontTexts:17];
label.textAlignment = NSTextAlignmentRight;
label.textColor = [UIColor whiteColor];
[cell setBackgroundColor:[UIColor clearColor]];

 UIView *view = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 320, 50)];
 view.backgroundColor = [PublicObject colorWithHexString:@"cd4110"];
 label.text = [filterData objectAtIndex:indexPath.row];
 view addSubview:label];
Run Code Online (Sandbox Code Playgroud)

现在我希望在我的视图中获得一个子视图,其中此子视图具有tag = 1并将其保存在另一个对象上,如下所示:

UILabel *tagLabel;
tagLabel = // I want get one subview in view where tag = 1 
Run Code Online (Sandbox Code Playgroud)

请帮我理解如何做到这一点.

objective-c uiview uilabel

27
推荐指数
5
解决办法
5万
查看次数

标签 统计

objective-c ×1

uilabel ×1

uiview ×1