@@ -39,7 +39,6 @@ @interface YALContextMenuTableView ()
3939@property (nonatomic , strong ) UITableViewCell<YALContextMenuCell> *selectedCell;
4040@property (nonatomic , strong ) NSIndexPath *dismissalIndexpath;
4141@property (nonatomic ) AnimatingState animatingState;
42- @property (nonatomic , strong ) UIWindow *window;
4342
4443@end
4544
@@ -65,22 +64,15 @@ - (instancetype)init {
6564 self.menuItemsSide = Right;
6665 self.menuItemsAppearanceDirection = FromTopToBottom;
6766
68- self.window = [[UIWindow alloc ] init ];
69- self.window .windowLevel = UIWindowLevelStatusBar + 1 .0f ;
70- self.window .backgroundColor = [[UIColor blackColor ] colorWithAlphaComponent: 0 .7f ];
71- self.frame = self.window .frame ;
72-
73- // self.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.7f];
74- self.backgroundColor = [UIColor clearColor ];
67+ self.backgroundColor = [[UIColor blackColor ] colorWithAlphaComponent: 0 .7f ];
7568 self.separatorColor = [UIColor colorWithRed: 181.0 /255.0 green: 181.0 /255.0 blue: 181.0 /255.0 alpha: 0 ];
7669 self.tableFooterView = [[UIView alloc ] initWithFrame: CGRectZero]; // Zero rect footer to clear empty rows UITableView draws
77- // [self.window addSubview:self];
7870 }
7971 return self;
8072}
8173
8274#pragma mark - Show / Dismiss
83- - (void )showWithAnimated : ( BOOL )animated {
75+ - (void )showInView : (UIView *) superview withEdgeInsets : (UIEdgeInsets) edgeInsets animated : ( BOOL )animated {
8476 if (self.animatingState !=Stable) {
8577 return ;
8678 }
@@ -91,17 +83,16 @@ - (void)showWithAnimated:(BOOL)animated{
9183
9284 self.dismissalIndexpath = nil ;
9385
94- [self .window addSubview: self ];
95- self.window .hidden = NO ;
86+ [superview addSubViewiew: self withSidesConstrainsInsets: edgeInsets];
9687
9788 if (animated) {
9889 self.animatingState = Showing;
99- self.window . alpha = 0 ;
90+ self.alpha = 0 ;
10091
10192 [self setUserInteractionEnabled: NO ];
10293
10394 [UIView animateWithDuration: self .animationDuration animations: ^{
104- self.window . alpha = 1 ;
95+ self.alpha = 1 ;
10596 } completion: ^(BOOL finished) {
10697 [self show: YES visibleCellsAnimated: YES ];
10798 [self setUserInteractionEnabled: YES ];
@@ -240,7 +231,6 @@ - (void)dismissSelf {
240231 BOOL clockwise = self.menuItemsSide == Right ? NO : YES ;
241232 [self show: NO cell: self .selectedCell animated: YES direction: direction clockwise: clockwise completion: ^(BOOL completed) {
242233 [self removeFromSuperview ];
243- self.window .hidden = YES ;
244234 if ([self .yalDelegate respondsToSelector: @selector (contextMenuTableView:didDismissWithIndexPath: )]) {
245235 [self .yalDelegate contextMenuTableView: self didDismissWithIndexPath: [self indexPathForCell: self .selectedCell]];
246236 }
@@ -258,7 +248,7 @@ - (void)shouldDismissSelf {
258248
259249- (void )prepareCellForShowAnimation : (UITableViewCell<YALContextMenuCell> *)cell {
260250
261- // [self resetAnimatedIconForCell:cell];
251+ [self resetAnimatedIconForCell: cell];
262252
263253 Direction direction;
264254 BOOL clockwise;
0 commit comments