Skip to content

Commit

Permalink
Categories for UIFont, UIPageViewController, NSMutableArray
Browse files Browse the repository at this point in the history
  • Loading branch information
WezSieTato committed Jan 24, 2016
1 parent 4148641 commit d622391
Show file tree
Hide file tree
Showing 9 changed files with 160 additions and 0 deletions.
18 changes: 18 additions & 0 deletions MSAddition.xcodeproj/project.pbxproj
Expand Up @@ -10,6 +10,9 @@
657AD92D1A9E223A00B27432 /* TestObject.m in Sources */ = {isa = PBXBuildFile; fileRef = 657AD92C1A9E223A00B27432 /* TestObject.m */; };
657AD92F1A9E248000B27432 /* MSDateTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 657AD92E1A9E248000B27432 /* MSDateTest.m */; };
9ED7EC041C5509CE0041F0A4 /* UIScrollView+MSAddition.m in Sources */ = {isa = PBXBuildFile; fileRef = 9ED7EC031C5509CE0041F0A4 /* UIScrollView+MSAddition.m */; };
9ED7EC071C550BB90041F0A4 /* UIPageViewController+MSAddition.m in Sources */ = {isa = PBXBuildFile; fileRef = 9ED7EC061C550BB90041F0A4 /* UIPageViewController+MSAddition.m */; };
9ED7EC0A1C550C2A0041F0A4 /* NSMutableArray+MSAddition.m in Sources */ = {isa = PBXBuildFile; fileRef = 9ED7EC091C550C2A0041F0A4 /* NSMutableArray+MSAddition.m */; };
9ED7EC0D1C550C870041F0A4 /* UIFont+MSAddition.m in Sources */ = {isa = PBXBuildFile; fileRef = 9ED7EC0C1C550C870041F0A4 /* UIFont+MSAddition.m */; };
D346DBB31A77A61F005E85E2 /* MSArrayTest.m in Sources */ = {isa = PBXBuildFile; fileRef = D346DBB21A77A61F005E85E2 /* MSArrayTest.m */; };
D3599B711A6F9E5300923BB3 /* UIView+MSAddition.m in Sources */ = {isa = PBXBuildFile; fileRef = D3599B701A6F9E5300923BB3 /* UIView+MSAddition.m */; };
D3599B731A6F9FF800923BB3 /* MSViewTest.m in Sources */ = {isa = PBXBuildFile; fileRef = D3599B721A6F9FF800923BB3 /* MSViewTest.m */; };
Expand Down Expand Up @@ -46,6 +49,12 @@
657AD92E1A9E248000B27432 /* MSDateTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MSDateTest.m; sourceTree = "<group>"; };
9ED7EC021C5509CE0041F0A4 /* UIScrollView+MSAddition.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIScrollView+MSAddition.h"; sourceTree = "<group>"; };
9ED7EC031C5509CE0041F0A4 /* UIScrollView+MSAddition.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIScrollView+MSAddition.m"; sourceTree = "<group>"; };
9ED7EC051C550BB90041F0A4 /* UIPageViewController+MSAddition.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIPageViewController+MSAddition.h"; sourceTree = "<group>"; };
9ED7EC061C550BB90041F0A4 /* UIPageViewController+MSAddition.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIPageViewController+MSAddition.m"; sourceTree = "<group>"; };
9ED7EC081C550C2A0041F0A4 /* NSMutableArray+MSAddition.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSMutableArray+MSAddition.h"; sourceTree = "<group>"; };
9ED7EC091C550C2A0041F0A4 /* NSMutableArray+MSAddition.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSMutableArray+MSAddition.m"; sourceTree = "<group>"; };
9ED7EC0B1C550C870041F0A4 /* UIFont+MSAddition.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIFont+MSAddition.h"; sourceTree = "<group>"; };
9ED7EC0C1C550C870041F0A4 /* UIFont+MSAddition.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIFont+MSAddition.m"; sourceTree = "<group>"; };
D346DBB21A77A61F005E85E2 /* MSArrayTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MSArrayTest.m; sourceTree = "<group>"; };
D3599B6F1A6F9E5300923BB3 /* UIView+MSAddition.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIView+MSAddition.h"; sourceTree = "<group>"; };
D3599B701A6F9E5300923BB3 /* UIView+MSAddition.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIView+MSAddition.m"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -140,6 +149,12 @@
D3B739581A89FF6400DCAB0D /* NSDate+MSAddition.m */,
9ED7EC021C5509CE0041F0A4 /* UIScrollView+MSAddition.h */,
9ED7EC031C5509CE0041F0A4 /* UIScrollView+MSAddition.m */,
9ED7EC051C550BB90041F0A4 /* UIPageViewController+MSAddition.h */,
9ED7EC061C550BB90041F0A4 /* UIPageViewController+MSAddition.m */,
9ED7EC081C550C2A0041F0A4 /* NSMutableArray+MSAddition.h */,
9ED7EC091C550C2A0041F0A4 /* NSMutableArray+MSAddition.m */,
9ED7EC0B1C550C870041F0A4 /* UIFont+MSAddition.h */,
9ED7EC0C1C550C870041F0A4 /* UIFont+MSAddition.m */,
);
path = MSAddition;
sourceTree = "<group>";
Expand Down Expand Up @@ -280,12 +295,15 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
9ED7EC0A1C550C2A0041F0A4 /* NSMutableArray+MSAddition.m in Sources */,
D3599B711A6F9E5300923BB3 /* UIView+MSAddition.m in Sources */,
9ED7EC041C5509CE0041F0A4 /* UIScrollView+MSAddition.m in Sources */,
D39113301A2F22B0002014D2 /* NSMutableString+MSAddition.m in Sources */,
9ED7EC071C550BB90041F0A4 /* UIPageViewController+MSAddition.m in Sources */,
D35FBA6E1A602C1800BB8A36 /* NSObject+MSAddition.m in Sources */,
D39113281A2F2239002014D2 /* main.m in Sources */,
D3B739591A89FF6400DCAB0D /* NSDate+MSAddition.m in Sources */,
9ED7EC0D1C550C870041F0A4 /* UIFont+MSAddition.m in Sources */,
D39113251A2F2239002014D2 /* AppDelegate.m in Sources */,
D391132F1A2F22B0002014D2 /* NSDictionary+MSAddition.m in Sources */,
D3780B631A84F42B0007C544 /* NSURL+MSAddition.m in Sources */,
Expand Down
15 changes: 15 additions & 0 deletions MSAddition/NSMutableArray+MSAddition.h
@@ -0,0 +1,15 @@
//
// NSMutableArray+MSAddition.h
// MSAddition
//
// Created by Marcin Stepnowski on 24.01.2016.
// Copyright © 2016 siema. All rights reserved.
//

#import <Foundation/Foundation.h>

@interface NSMutableArray (MSAddition)

- (void)ms_moveObjectFromPosition:(NSUInteger)fromPosition toIndex:(NSUInteger)endPosition;

@end
20 changes: 20 additions & 0 deletions MSAddition/NSMutableArray+MSAddition.m
@@ -0,0 +1,20 @@
//
// NSMutableArray+MSAddition.m
// MSAddition
//
// Created by Marcin Stepnowski on 24.01.2016.
// Copyright © 2016 siema. All rights reserved.
//

#import "NSMutableArray+MSAddition.h"

@implementation NSMutableArray (MSAddition)

- (void)ms_moveObjectFromPosition:(NSUInteger)fromPosition toIndex:(NSUInteger)endPosition
{
id object = self[fromPosition];
[self removeObjectAtIndex:fromPosition];
[self insertObject:object atIndex:endPosition];
}

@end
15 changes: 15 additions & 0 deletions MSAddition/UIFont+MSAddition.h
@@ -0,0 +1,15 @@
//
// UIFont+MSAddition.h
// MSAddition
//
// Created by Marcin Stepnowski on 24.01.2016.
// Copyright © 2016 siema. All rights reserved.
//

#import <UIKit/UIKit.h>

@interface UIFont (MSAddition)

+(void)ms_printAllFontNames;

@end
21 changes: 21 additions & 0 deletions MSAddition/UIFont+MSAddition.m
@@ -0,0 +1,21 @@
//
// UIFont+MSAddition.m
// MSAddition
//
// Created by Marcin Stepnowski on 24.01.2016.
// Copyright © 2016 siema. All rights reserved.
//

#import "UIFont+MSAddition.h"

@implementation UIFont (MSAddition)

+(void)ms_printAllFontNames{
for (NSString *fontFamilyName in [UIFont familyNames]) {
for (NSString *fontName in [UIFont fontNamesForFamilyName:fontFamilyName]) {
NSLog(@"Family: %@ Font: %@", fontFamilyName, fontName);
}
}
}

@end
15 changes: 15 additions & 0 deletions MSAddition/UIPageViewController+MSAddition.h
@@ -0,0 +1,15 @@
//
// UIPageViewController+MSAddition.h
// MSAddition
//
// Created by Marcin Stepnowski on 24.01.2016.
// Copyright © 2016 siema. All rights reserved.
//

#import <UIKit/UIKit.h>

@interface UIPageViewController (MSAddition)

@property (nonatomic, readonly) UIScrollView* ms_scrollView;

@end
22 changes: 22 additions & 0 deletions MSAddition/UIPageViewController+MSAddition.m
@@ -0,0 +1,22 @@
//
// UIPageViewController+MSAddition.m
// MSAddition
//
// Created by Marcin Stepnowski on 24.01.2016.
// Copyright © 2016 siema. All rights reserved.
//

#import "UIPageViewController+MSAddition.h"

@implementation UIPageViewController (MSAddition)

-(UIScrollView*)ms_scrollView{
for (UIView *view in self.view.subviews) {
if ([view isKindOfClass:[UIScrollView class]]) {
return (UIScrollView*)view;
}
}
return nil;
}

@end
5 changes: 5 additions & 0 deletions MSAddition/UIView+MSAddition.h
Expand Up @@ -15,5 +15,10 @@
@property (nonatomic, readonly) NSArray <UIView *>* ms_allSubViews;

-(void)ms_addSubviewWithFitToParentConstraints:(UIView *)subview;
-(void)ms_addTapToHideKeyboardRecognizer;
-(void)ms_hideKeyboard;
-(void)ms_animateConstraintWithDuration:(NSTimeInterval)duration animations:(void (^)(void))animations
withCompletion:(void (^)(BOOL finished))completion ;
-(void)ms_animateConstraintWithDuration:(NSTimeInterval)duration animations:(void (^)(void))animations;

@end
29 changes: 29 additions & 0 deletions MSAddition/UIView+MSAddition.m
Expand Up @@ -40,6 +40,17 @@ -(CGSize)ms_sizeFrame{
return [arr copy];
}


-(void)ms_addTapToHideKeyboardRecognizer{
UITapGestureRecognizer *tapRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(ms_hideKeyboard)];
tapRecognizer.cancelsTouchesInView = NO;
[self addGestureRecognizer:tapRecognizer];
}

-(void)ms_hideKeyboard{
[self endEditing:YES];
}

-(void)ms_addSubviewWithFitToParentConstraints:(UIView *)subview{
[self addSubview: subview];

Expand All @@ -56,4 +67,22 @@ -(void)ms_addSubviewWithFitToParentConstraints:(UIView *)subview{
views:NSDictionaryOfVariableBindings(subview)]];
}

-(void)ms_animateConstraintWithDuration:(NSTimeInterval)duration animations:(void (^)(void))animations
withCompletion:(void (^)(BOOL))completion{

animations();

[self setNeedsUpdateConstraints];
[UIView animateWithDuration:duration animations:^{
[self layoutIfNeeded];
} completion:^(BOOL finished) {
if(completion)
completion(finished);
}];
}

-(void)ms_animateConstraintWithDuration:(NSTimeInterval)duration animations:(void (^)(void))animations{
[self ms_animateConstraintWithDuration:duration animations:animations withCompletion:nil];
}

@end

0 comments on commit d622391

Please sign in to comment.