feat:add view tag and findViewByTag

This commit is contained in:
刘涛
2020-07-04 10:04:40 +08:00
committed by osborn
parent 42a8eb4069
commit f693719974
9 changed files with 131 additions and 16 deletions

View File

@@ -1686,6 +1686,12 @@ class View {
}
return f;
}
findViewByTag(tag) {
if (tag === this.tag) {
return this;
}
return undefined;
}
/** Anchor start*/
get left() {
return this.x;
@@ -1922,6 +1928,21 @@ class Superview extends View {
}
}
}
findViewByTag(tag) {
if (tag === this.tag) {
return this;
}
return this.findViewTraversal(this, tag);
}
findViewTraversal(view, tag) {
for (let v of view.allSubviews()) {
let find = v.findViewByTag(tag);
if (find) {
return find;
}
}
return undefined;
}
isDirty() {
if (super.isDirty()) {
return true;