Skip to content

Instantly share code, notes, and snippets.

@cemck
cemck / listSubviews.m
Last active May 24, 2019 23:33
objc - list all subviews of some view
- (void)listSubviewsOfView:(UIView *)view {
// Get the subviews of the view
NSArray *subviews = [view subviews];
// Return if there are no subviews
if ([subviews count] == 0) return; // COUNT CHECK LINE
for (UIView *subview in subviews) {
// Do what you want to do with the subview
NSLog(@"%@", subview);
UIView *newView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 35)];
newView.backgroundColor=[UIColor redColor];
UITextView *mytext = [[UITextView alloc] initWithFrame:CGRectMake(5.0, 0.0, 100.0, 28.0)];
mytext.backgroundColor = [UIColor clearColor];
mytext.textColor = [UIColor blackColor];
mytext.editable = NO;
mytext.font = [UIFont systemFontOfSize:15];
mytext.text = @"Mytext";
mytext.scrollEnabled=NO;