forked from facebookarchive/AsyncDisplayKit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathASTextKitShadower.h
More file actions
executable file
·70 lines (53 loc) · 2.33 KB
/
ASTextKitShadower.h
File metadata and controls
executable file
·70 lines (53 loc) · 2.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
//
// ASTextKitShadower.h
// AsyncDisplayKit
//
// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
// This source code is licensed under the BSD-style license found in the
// LICENSE file in the root directory of this source tree. An additional grant
// of patent rights can be found in the PATENTS file in the same directory.
//
#import <UIKit/UIKit.h>
/**
* @abstract an immutable class for calculating shadow padding drawing a shadowed background for text
*/
@interface ASTextKitShadower : NSObject
- (instancetype)initWithShadowOffset:(CGSize)shadowOffset
shadowColor:(UIColor *)shadowColor
shadowOpacity:(CGFloat)shadowOpacity
shadowRadius:(CGFloat)shadowRadius;
/**
* @abstract The offset from the top-left corner at which the shadow starts.
* @discussion A positive width will move the shadow to the right.
* A positive height will move the shadow downwards.
*/
@property (nonatomic, readonly, assign) CGSize shadowOffset;
//! CGColor in which the shadow is drawn
@property (nonatomic, readonly, strong) UIColor *shadowColor;
//! Alpha of the shadow
@property (nonatomic, readonly, assign) CGFloat shadowOpacity;
//! Radius, in pixels
@property (nonatomic, readonly, assign) CGFloat shadowRadius;
/**
* @abstract The edge insets which represent shadow padding
* @discussion Each edge inset is less than or equal to zero.
*
* Example:
* CGRect boundsWithoutShadowPadding; // Large enough to fit text, not large enough to fit the shadow as well
* UIEdgeInsets shadowPadding = [shadower shadowPadding];
* CGRect boundsWithShadowPadding = UIEdgeInsetsRect(boundsWithoutShadowPadding, shadowPadding);
*/
- (UIEdgeInsets)shadowPadding;
- (CGSize)insetSizeWithConstrainedSize:(CGSize)constrainedSize;
- (CGRect)insetRectWithConstrainedRect:(CGRect)constrainedRect;
- (CGSize)outsetSizeWithInsetSize:(CGSize)insetSize;
- (CGRect)outsetRectWithInsetRect:(CGRect)insetRect;
- (CGRect)offsetRectWithInternalRect:(CGRect)internalRect;
- (CGPoint)offsetPointWithInternalPoint:(CGPoint)internalPoint;
- (CGPoint)offsetPointWithExternalPoint:(CGPoint)externalPoint;
/**
* @abstract draws the shadow for text in the provided CGContext
* @discussion Call within the text node's +drawRect method
*/
- (void)setShadowInContext:(CGContextRef)context;
@end