Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bridge CTFontRef directly to UIFont #8

Merged
merged 2 commits into from
Oct 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions MJNIndexForTableView/MJNIndexView.m
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ - (void) initialiseAllAttributes
NSCache *itemAttributes = [@{@"item":item,
@"origin":newValueForPoint,
@"position":newValueForPoint,
@"font":(__bridge_transfer id)CTFontCreateWithName((__bridge CFStringRef)self.font.fontName, self.font.pointSize, NULL),
@"font":self.font,
@"color":self.fontColor,
@"alpha":alpha,
@"zPosition":zPosition,
Expand Down Expand Up @@ -454,7 +454,7 @@ - (void) resetPosition
for (NSCache *itemAttributes in self.itemsAtrributes){
CGPoint origin = [[itemAttributes objectForKey:@"origin"] CGPointValue];
[itemAttributes setObject:[NSValue valueWithCGPoint:origin] forKey:@"position"];
[itemAttributes setObject:(__bridge_transfer id)CTFontCreateWithName((__bridge CFStringRef)self.font.fontName, self.font.pointSize, NULL) forKey:@"font"];
[itemAttributes setObject:self.font forKey:@"font"];
[itemAttributes setObject:@(1.0) forKey:@"alpha"];
[itemAttributes setObject:self.fontColor forKey:@"color"];
[itemAttributes setObject:@(5.0) forKey:@"zPosition"];
Expand Down Expand Up @@ -537,8 +537,9 @@ - (void) positionForIndexItemsWhilePanLocation:(CGPoint)location
alpha = colorChange;
} else alpha = 1.0;

[itemAttributes setObject:(__bridge_transfer id)CTFontCreateWithName((__bridge CFStringRef)self.font.fontName, fontSize, NULL) forKey:@"font"];

[itemAttributes setObject:[self.font fontWithSize:fontSize]
forKey:@"font"];

[itemAttributes setObject:fontColor forKey:@"color"];

// checking if the item is the most deflected one -> it means it is the selected one
Expand All @@ -552,7 +553,8 @@ - (void) positionForIndexItemsWhilePanLocation:(CGPoint)location
if (selectedInRange || firstItemInRange || lastItemInRange) {
alpha = 1.0;

[itemAttributes setObject:(__bridge_transfer id)CTFontCreateWithName((__bridge CFStringRef)self.selectedItemFont.fontName, fontSize, NULL) forKey:@"font"];
[itemAttributes setObject:[self.font fontWithSize:fontSize]
forKey:@"font"];
[itemAttributes setObject:self.selectedItemFontColor forKey:@"color"];
[itemAttributes setObject:@(10.0) forKey:@"zPosition"];
if (!self.getSelectedItemsAfterPanGestureIsFinished && [self.section integerValue] != section) {
Expand All @@ -572,7 +574,7 @@ - (void) positionForIndexItemsWhilePanLocation:(CGPoint)location

point.x = origin.x;
alpha = 1.0;
[itemAttributes setObject:(__bridge_transfer id)CTFontCreateWithName((__bridge CFStringRef)self.font.fontName, self.font.pointSize, NULL) forKey:@"font"];
[itemAttributes setObject:self.font forKey:@"font"];
fontColor = self.fontColor;
[itemAttributes setObject:self.fontColor forKey:@"color"];
[itemAttributes setObject:@(5.0) forKey:@"zPosition"];
Expand Down
12 changes: 7 additions & 5 deletions MJNIndexView.m
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ - (void) initialiseAllAttributes
NSCache *itemAttributes = [@{@"item":item,
@"origin":newValueForPoint,
@"position":newValueForPoint,
@"font":(__bridge_transfer id)CTFontCreateWithName((__bridge CFStringRef)self.font.fontName, self.font.pointSize, NULL),
@"font":self.font,
@"color":self.fontColor,
@"alpha":alpha,
@"zPosition":zPosition,
Expand Down Expand Up @@ -454,7 +454,7 @@ - (void) resetPosition
for (NSCache *itemAttributes in self.itemsAtrributes){
CGPoint origin = [[itemAttributes objectForKey:@"origin"] CGPointValue];
[itemAttributes setObject:[NSValue valueWithCGPoint:origin] forKey:@"position"];
[itemAttributes setObject:(__bridge_transfer id)CTFontCreateWithName((__bridge CFStringRef)self.font.fontName, self.font.pointSize, NULL) forKey:@"font"];
[itemAttributes setObject:self.font forKey:@"font"];
[itemAttributes setObject:@(1.0) forKey:@"alpha"];
[itemAttributes setObject:self.fontColor forKey:@"color"];
[itemAttributes setObject:@(5.0) forKey:@"zPosition"];
Expand Down Expand Up @@ -537,7 +537,8 @@ - (void) positionForIndexItemsWhilePanLocation:(CGPoint)location
alpha = colorChange;
} else alpha = 1.0;

[itemAttributes setObject:(__bridge_transfer id)CTFontCreateWithName((__bridge CFStringRef)self.font.fontName, fontSize, NULL) forKey:@"font"];
[itemAttributes setObject:[self.font fontWithSize:fontSize]
forKey:@"font"];

[itemAttributes setObject:fontColor forKey:@"color"];

Expand All @@ -552,7 +553,8 @@ - (void) positionForIndexItemsWhilePanLocation:(CGPoint)location
if (selectedInRange || firstItemInRange || lastItemInRange) {
alpha = 1.0;

[itemAttributes setObject:(__bridge_transfer id)CTFontCreateWithName((__bridge CFStringRef)self.selectedItemFont.fontName, fontSize, NULL) forKey:@"font"];
[itemAttributes setObject:[self.font fontWithSize:fontSize]
forKey:@"font"];
[itemAttributes setObject:self.selectedItemFontColor forKey:@"color"];
[itemAttributes setObject:@(10.0) forKey:@"zPosition"];
if (!self.getSelectedItemsAfterPanGestureIsFinished && [self.section integerValue] != section) {
Expand All @@ -572,7 +574,7 @@ - (void) positionForIndexItemsWhilePanLocation:(CGPoint)location

point.x = origin.x;
alpha = 1.0;
[itemAttributes setObject:(__bridge_transfer id)CTFontCreateWithName((__bridge CFStringRef)self.font.fontName, self.font.pointSize, NULL) forKey:@"font"];
[itemAttributes setObject:self.font forKey:@"font"];
fontColor = self.fontColor;
[itemAttributes setObject:self.fontColor forKey:@"color"];
[itemAttributes setObject:@(5.0) forKey:@"zPosition"];
Expand Down