Skip to content

Instantly share code, notes, and snippets.

View ourui's full-sized avatar

Ourui ourui

  • iQIYI
  • ShangHai. China
View GitHub Profile
@ourui
ourui / DisplayViewHierarchy.m
Last active December 23, 2015 06:05
Recursively Print UIView Hierarchy
//po [[UIWindow keyWindow] recursiveDescription] //private api
// Recursively travel down the view tree, increasing the indentation level for children
- (void)dumpView:(UIView *)aView atIndent:(int)indent into:(NSMutableString *)outstring
{
for (int i = 0; i < indent; i++) [outstring appendString:@"--"];
[outstring appendFormat:@"[%2d] %@\n", indent, [[aView class] description]];
for (UIView *view in [aView subviews])
[self dumpView:view atIndent:indent + 1 into:outstring];
}
@ourui
ourui / ChineseToPinYin.m
Last active December 23, 2015 06:05
Covert Chinese Word To PinYin
NSMutableString *ms = [[NSMutableString alloc] initWithString:@"我是中国人"];
if (CFStringTransform((__bridge CFMutableStringRef)ms, 0, kCFStringTransformMandarinLatin, NO)) {
NSLog(@"Pingying: %@", ms); // wǒ shì zhōng guó rén
}
if (CFStringTransform((__bridge CFMutableStringRef)ms, 0, kCFStringTransformStripDiacritics, NO)) {
NSLog(@"Pingying: %@", ms); // wo shi zhong guo ren
}