Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 990d3e9

Browse files
wanghenghengEase
authored and
Ease
committed
Category - 打印 View 的子视图的目录树
1 parent 02e9fac commit 990d3e9

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

‎Coding_iOS/Util/OC_Category/UIView+Common.h‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,14 @@ typedef NS_ENUM(NSInteger, BadgePositionType) {
7272

7373
- (void)removeViewWithTag:(NSInteger)tag;
7474
- (CGSize)doubleSizeOfFrame;
75+
- (void)outputSubviewTree;//输出子视图的目录树
7576

7677
+ (CGRect)frameWithOutNav;
7778
+ (UIViewAnimationOptions)animationOptionsForCurve:(UIViewAnimationCurve)curve;
7879
+ (UIView *)lineViewWithPointYY:(CGFloat)pointY;
7980
+ (UIView *)lineViewWithPointYY:(CGFloat)pointY andColor:(UIColor *)color;
8081
+ (UIView *)lineViewWithPointYY:(CGFloat)pointY andColor:(UIColor *)color andLeftSpace:(CGFloat)leftSpace;
81-
82+
+ (void)outputTreeInView:(UIView *)viewwithSeparatorCount:(NSInteger)count;//输出某个View的subview目录
8283

8384
#pragma mark LoadingView
8485
@property (strong, nonatomic) EaseLoadingView *loadingView;

‎Coding_iOS/Util/OC_Category/UIView+Common.m‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,26 @@ + (UIView *)lineViewWithPointYY:(CGFloat)pointY andColor:(UIColor *)color andLef
253253
return lineView;
254254
}
255255

256+
+ (void)outputTreeInView:(UIView *)view withSeparatorCount:(NSInteger)count{
257+
NSString *outputStr = @"";
258+
outputStr = [outputStr stringByReplacingCharactersInRange:NSMakeRange(0, count) withString:@"-"];
259+
outputStr = [outputStr stringByAppendingString:view.description];
260+
printf("%s\n", outputStr.UTF8String);
261+
262+
if (view.subviews.count == 0) {
263+
return;
264+
}else{
265+
count++;
266+
for (UIView *subV in view.subviews) {
267+
[self outputTreeInView:subV withSeparatorCount:count];
268+
}
269+
}
270+
}
271+
272+
- (void)outputSubviewTree{
273+
[UIView outputTreeInView:self withSeparatorCount:0];
274+
}
275+
256276
- (void)addLineUp:(BOOL)hasUp andDown:(BOOL)hasDown{
257277
[self addLineUp:hasUp andDown:hasDown andColor:[UIColor colorWithHexString:@"0xc8c7cc"]];
258278
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /