Nsstring *xml = [self digView:self.view];
[xml writetoFile:@"/Users/frankhou/Desktop/view.xml"
atomically:YES
encoding:NSUTF8StringEncoding
error:nil];
- (Nsstring *)digView:(UIView *)view
{
if ([view isKindOfClass:[UITableViewCell class]]) return @"";
NSMutableString *xml = [NSMutableString string];
[xml appendFormat:@"<%@ frame=\"%@\"",view.class,NsstringFromCGRect(view.frame)];
if (!CGPointEqualToPoint(view.bounds.origin,CGPointZero)) {
[xml appendFormat:@" bounds=\"%@\"",NsstringFromCGRect(view.bounds)];
}
if ([view isKindOfClass:[UIScrollView class]]) {
UIScrollView *scroll = (UIScrollView *)view;
if (!UIEdgeInsetsEqualToEdgeInsets(UIEdgeInsetsZero,scroll.contentInset)) {
[xml appendFormat:@" contentInset=\"%@\"",NsstringFromUIEdgeInsets(scroll.contentInset)];
}
}
if (view.subviews.count == 0) {
[xml appendString:@" />"];
return xml;
} else {
[xml appendString:@">"];
}
for (UIView*child in view.subviews) {
Nsstring *childXml = [self digView:child];
[xml appendString:childXml];
}
[xml appendFormat:@"</%@>",view.class];
return xml;
}