Skip to content

Commit

Permalink
* iOS app extension support
Browse files Browse the repository at this point in the history
  • Loading branch information
Muzaffar Mahkamov committed Jun 29, 2017
1 parent 7dbd771 commit 3549c63
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 8 deletions.
22 changes: 21 additions & 1 deletion MGSwipeTableCell/MGSwipeButton.m
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ -(void) centerIconOverText
-(void) centerIconOverTextWithSpacing: (CGFloat) spacing {
CGSize size = self.imageView.image.size;

if ([UIDevice currentDevice].systemVersion.floatValue >= 9.0 && [UIApplication sharedApplication].userInterfaceLayoutDirection == UIUserInterfaceLayoutDirectionRightToLeft) {
if ([UIDevice currentDevice].systemVersion.floatValue >= 9.0 && [self isRTLLocale]) {
self.titleEdgeInsets = UIEdgeInsetsMake(0.0,
0.0,
-(size.height + spacing),
Expand Down Expand Up @@ -156,4 +156,24 @@ -(void) iconTintColor:(UIColor *)tintColor
self.tintColor = tintColor;
}

- (BOOL)isAppExtension
{
return [[NSBundle mainBundle].executablePath rangeOfString:@".appex/"].location != NSNotFound;
}


-(BOOL) isRTLLocale
{
if ([[UIView class] respondsToSelector:@selector(userInterfaceLayoutDirectionForSemanticContentAttribute:)]) {
return [UIView userInterfaceLayoutDirectionForSemanticContentAttribute:self.semanticContentAttribute] == UIUserInterfaceLayoutDirectionRightToLeft;
} else {
if ([self isAppExtension]) {
return [NSLocale characterDirectionForLanguage:[[NSLocale currentLocale] objectForKey:NSLocaleLanguageCode]]==NSLocaleLanguageDirectionRightToLeft;
} else {
UIApplication *application = [UIApplication performSelector:@selector(sharedApplication)];
return application.userInterfaceLayoutDirection == UIUserInterfaceLayoutDirectionRightToLeft;
}
}
}

@end
20 changes: 13 additions & 7 deletions MGSwipeTableCell/MGSwipeTableCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -651,18 +651,24 @@ -(void) cleanViews
}
}

- (BOOL)isAppExtension
{
return [[NSBundle mainBundle].executablePath rangeOfString:@".appex/"].location != NSNotFound;
}


-(BOOL) isRTLLocale
{
if ([[UIView class] respondsToSelector:@selector(userInterfaceLayoutDirectionForSemanticContentAttribute:)]) {
return [UIView userInterfaceLayoutDirectionForSemanticContentAttribute:self.semanticContentAttribute] == UIUserInterfaceLayoutDirectionRightToLeft;
} else {
if ([self isAppExtension]) {
return [NSLocale characterDirectionForLanguage:[[NSLocale currentLocale] objectForKey:NSLocaleLanguageCode]]==NSLocaleLanguageDirectionRightToLeft;
} else {
UIApplication *application = [UIApplication performSelector:@selector(sharedApplication)];
return application.userInterfaceLayoutDirection == UIUserInterfaceLayoutDirectionRightToLeft;
}
}
#ifndef TARGET_IS_EXTENSION
else {
return [UIApplication sharedApplication].userInterfaceLayoutDirection == UIUserInterfaceLayoutDirectionRightToLeft;
}
#else
return NO;
#endif
}

-(void) fixRegionAndAccesoryViews
Expand Down

0 comments on commit 3549c63

Please sign in to comment.