This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyDataModel: BindableObject { | |
var didChange = PassthroughSubject<Void, Never>() | |
} | |
extension MyDataModel: NSFetchedResultsControllerDelegate { | |
func controllerDidChangeContent(_ controller: NSFetchedResultsController<NSFetchRequestResult>) { | |
didChange.send() | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyDefaults: BindableObject { | |
public var didChange: AnyPublisher<Bool, Never> | |
init() { | |
let defaults = UserDefaults.standard | |
didChange = Publishers.Merge( | |
defaults.publisher(for: \.userOption1), | |
defaults.publisher(for: \.userOption2) | |
) | |
.receive(on: RunLoop.main) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Mask | |
CAShapeLayer *maskLayer = [CAShapeLayer layer]; | |
maskLayer.fillRule = kCAFillRuleEvenOdd; | |
maskLayer.frame = CGRectMake(0, 0, self.notificationsTabBarButton.frame.size.width, self.notificationsTabBarButton.frame.size.height); | |
CGPoint circleCenter = self.notificationsBadge.center; | |
CGFloat innerCircleRadius = self.notificationsBadge.frame.size.width/2; | |
CGFloat circleRadius = innerCircleRadius + 2; | |
UIBezierPath *circlePath = [UIBezierPath bezierPathWithArcCenter:circleCenter radius:circleRadius startAngle:0.0 endAngle:M_PI * 2.0 clockwise:YES]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
UIBezierPath* bezierPath = [UIBezierPath bezierPath]; | |
[bezierPath moveToPoint:CGPointMake(0.0, 5.0)]; | |
[bezierPath addArcWithCenter:CGPointMake(5.0, 5.0) radius:5.0 startAngle:DEGREES_TO_RADIANS(180) endAngle:DEGREES_TO_RADIANS(-90) clockwise:YES]; | |
[bezierPath addLineToPoint:CGPointMake(5.0, 20.0)]; | |
[bezierPath closePath]; | |
CAShapeLayer *shape = [CAShapeLayer layer]; | |
shape.frame = self.poster.bounds; | |
shape.path = bezierPath.CGPath; | |
shape.fillColor = [UIColor clearColor].CGColor; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CAShapeLayer *maskLayer = [CAShapeLayer layer]; | |
maskLayer.frame = CGRectMake(0, 0, self.poster.frame.size.width, self.poster.frame.size.height); | |
UIBezierPath* bezierPath = [UIBezierPath bezierPath]; | |
[bezierPath moveToPoint:CGPointMake(0.0, 5.0)]; | |
[bezierPath addArcWithCenter:CGPointMake(5.0, 5.0) radius:5.0 startAngle:DEGREES_TO_RADIANS(180) endAngle:DEGREES_TO_RADIANS(-90) clockwise:YES]; | |
[bezierPath addLineToPoint:CGPointMake(107.0, 0.0)]; | |
[bezierPath addArcWithCenter:CGPointMake(107.0, 5.0) radius:5.0 startAngle:DEGREES_TO_RADIANS(-90) endAngle:DEGREES_TO_RADIANS(0) clockwise:YES]; | |
[bezierPath addLineToPoint:CGPointMake(112.0, 89.0)]; | |
[bezierPath addArcWithCenter:CGPointMake(107.0, 89.0) radius:5.0 startAngle:DEGREES_TO_RADIANS(0) endAngle:DEGREES_TO_RADIANS(90) clockwise:YES]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Create mask layer | |
UIImage *maskImage = [UIImage imageNamed:@"posterMask"]; | |
CAShapeLayer* maskLayer = [CAShapeLayer layer]; | |
maskLayer.frame = CGRectMake(0, 0, maskImage.size.width,maskImage.size.height); | |
maskLayer.contents = (__bridge id)maskImage.CGImage; | |
self.poster.layer.mask = maskLayer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void) viewWillAppear:(BOOL)animated { | |
UIToolbar* toolbar = [[UIToolbar alloc]initWithFrame:CGRectMake(0, 0, 320, 50)]; | |
toolbar.barStyle = UIBarStyleBlackTranslucent; | |
toolbar.items = [NSArray arrayWithObjects: | |
[[UIBarButtonItem alloc]initWithTitle:@"Previous" style:UIBarButtonItemStyleBordered target:self action:@selector(previous:)], | |
[[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil], | |
[[UIBarButtonItem alloc]initWithTitle:@"Next" style:UIBarButtonItemStyleDone target:self action:@selector(next:)], | |
nil]; | |
[toolbar sizeToFit]; | |
for (UIView * view in self.view.subviews) { |
NewerOlder