diff --git a/docs/_docs/layout2-layoutspec-types.md b/docs/_docs/layout2-layoutspec-types.md index f382df0d42..e0ce92fde5 100755 --- a/docs/_docs/layout2-layoutspec-types.md +++ b/docs/_docs/layout2-layoutspec-types.md @@ -19,6 +19,7 @@ The following `ASLayoutSpec` subclasses can be used to compose simple or very co
ASRelativeLayoutSpecASAbsoluteLayoutSpecASCornerLayoutSpec
+
+`ASCornerLayoutSpec` takes good care of its own size calculation. The best scenario to explain this would be the case that adding a small badge view at the corner of user's avatar image and there is no need to worry about the fact that little-exceeded badge frame (which out of avatar image frame) may affect the whole layout size. By default, the size of corner element will not be added to layout size, only if you manually turn on the `wrapsCorner` property.
+
+`ASCornerLayoutSpec` is introduced from version 2.7 and above.
+
+
+- (ASLayoutSpec *)layoutSpecThatFits:(ASSizeRange)constrainedSize
+{
+ ...
+ // Layout the center of badge to the top right corner of avatar.
+ ASCornerLayoutSpec *cornerSpec = [ASCornerLayoutSpec cornerLayoutSpecWithChild:self.avatarNode corner:self.badgeNode location:ASCornerLayoutLocationTopRight];
+ // Slightly shift center of badge inside of avatar.
+ cornerSpec.offset = CGPointMake(-3, 3);
+ ...
+}
+
+
+
+