Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
github.com/wenchaoios/fscalendar
iOS8/9 | iOS10 |
---|---|
To customize your own cell, view DIY Example in
Example-Swift
orExample-Objc
Single-Selection Swipe-To-Choose | Multiple-Selection Swipe-To-Choose | DIY Swipe-To-Choose |
---|---|---|
use_frameworks!
target '<Your Target Name>' do
pod 'FSCalendar'
end
target '<Your Target Name>' do
pod 'FSCalendar'
end
NSCalendarExtension is required to get iOS7 compatibility.
github "WenchaoD/FSCalendar"
Add dependency:
.package(url: "https://github.com/WenchaoD/FSCalendar.git", from: "2.8.4")
FSCalendar
folder into your project. 👍Alternatively to give it a test run, simply press
command+u
inExample-Objc
orExample-Swift
and launch the UITest Target.
Only the methods marked "👍" support IBInspectable / IBDesignable feature. Have fun with Interface builder
1、 Drag an UIView object to ViewController Scene
2、 Change the Custom Class
to FSCalendar
3、 Link dataSource
and delegate
to the ViewController
4、 Finally, implement FSCalendarDataSource
and FSCalendarDelegate
in your ViewController
@property (weak , nonatomic) FSCalendar *calendar;
// In loadView(Recommended) or viewDidLoad
FSCalendar *calendar = [[FSCalendar alloc] initWithFrame:CGRectMake(0, 0, 320, 300)];
calendar.dataSource = self;
calendar.delegate = self;
[self.view addSubview:calendar];
self.calendar = calendar;
FSCalendar
in swift, you need to Create Bridge Header first.fileprivate weak var calendar: FSCalendar!
// In loadView or viewDidLoad
let calendar = FSCalendar(frame: CGRect(x: 0, y: 0, width: 320, height: 300))
calendar.dataSource = self
calendar.delegate = self
view.addSubview(calendar)
self.calendar = calendar
To use FSCalendar in Swift3, see
Example-Swift
for details.
FSCalendar
doesn't update frame by itself, Please implement
- (void)calendar:(FSCalendar *)calendar boundingRectWillChange:(CGRect)bounds animated:(BOOL)animated
{
self.calendarHeightConstraint.constant = CGRectGetHeight(bounds);
// Do other updates here
[self.view layoutIfNeeded];
}
- (void)calendar:(FSCalendar *)calendar boundingRectWillChange:(CGRect)bounds animated:(BOOL)animated
{
calendar.frame = (CGRect){calendar.frame.origin,bounds.size};
// Do other updates here
}
- (void)calendar:(FSCalendar *)calendar boundingRectWillChange:(CGRect)bounds animated:(BOOL)animated
{
[calendar mas_updateConstraints:^(MASConstraintMaker *make) {
make.height.equalTo(@(bounds.size.height));
// Do other updates
}];
[self.view layoutIfNeeded];
}
func calendar(_ calendar: FSCalendar, boundingRectWillChange bounds: CGRect, animated: Bool) {
calendar.snp.updateConstraints { (make) in
make.height.equalTo(bounds.height)
// Do other updates
}
self.view.layoutIfNeeded()
}
In
Swift3
,NSDate
andNSDateFormatter
have been renamed to Date and DateFormatter , seeExample-Swift
for details.
self.gregorian = [NSCalendar calendarWithIdentifier:NSCalendarIdentifierGregorian];
Then:
NSDate *date = [gregorian dateWithEra:1 year:2016 month:9 day:10 hour:0 minute:0 second:0 nanosecond:0];
// 2016-09-10 00:00:00
self.formatter = [[NSDateFormatter alloc] init];
self.formatter.dateFormat = @"yyyy-MM-dd";
Then:
NSDate *date = [self.formatter dateFromString:@"2016-09-10"];
self.formatter = [[NSDateFormatter alloc] init];
self.formatter.dateFormat = @"yyyy/MM/dd";
NSString *string = [self.formatter stringFromDate:date];
NSLog(@"Date is %@", string);
self.gregorian = [NSCalendar calendarWithIdentifier:NSCalendarIdentifierGregorian];
NSInteger era = [self.gregorian component:NSCalendarUnitEra fromDate:date];
NSInteger year = [self.gregorian component:NSCalendarUnitYear fromDate:date];
NSInteger month = [self.gregorian component:NSCalendarUnitMonth fromDate:date];
NSInteger day = [self.gregorian component:NSCalendarUnitDay fromDate:date];
NSInteger hour = [self.gregorian component:NSCalendarUnitHour fromDate:date];
NSInteger minute = [self.gregorian component:NSCalendarUnitMinute fromDate:date];
...
NSDate *nextMonth = [self.gregorain dateByAddingUnit:NSCalendarUnitMonth value:1 toDate:date options:0];
NSDate *nextDay = [self.gregorain dateByAddingUnit:NSCalendarUnitDay value:1 toDate:date options:0];
BOOL isToday = [self.gregorian isDateInToday:date];
BOOL isYesterday = [self.gregorian isDateInYesterday:date];
BOOL isTomorrow = [self.gregorian isDateInTomorrow:date];
BOOL isWeekend = [self.gregorian isDateInWeekend:date];
BOOL sameDay = [self.gregorian isDate:date1 inSameDayAsDate:date2];
// Yes if the date1 and date2 are in same day
[self.gregorian compareDate:date1 toDate:date2 toUnitGranularity:unit];
// compare the era/year/month/day/hour/minute .etc ...
// return NSOrderAscending/NSOrderSame/NSOrderDecending
BOOL inSameUnit = [self.gregorian isDate:date1 equalToDate:date2 toUnitGranularity:unit];
// if the given unit (era/year/month/day/hour/minute .etc) are the same
If your made a beautiful calendar with this library in your app, please take a screen shot and @me in twitter. Your help really means a lot to me!
FSCalendar is available under the MIT license. See the LICENSE file for more info.
FAQs
Unknown package
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.