设置视图控制器.h
#import <UIKit/UIKit.h>
#import "SetNameCell.h"
#import "SetDateCell.h"
#import "UIViewController+Alerts.h"
@class settingViewController;
@protocol settingViewDelegate <NSObject>
- (void)modalDoneDel :(settingViewController *)controller;
@end
@interface settingViewController : UIViewController <UITableViewDelegate, UITableViewDataSource> {
SetNameCell *nameCell;
SetDateCell *dateCell;
}
@property (nonatomic, assign) id <settingViewDelegate> delegate;
@property (weak, nonatomic) IBOutlet UITableView *tableView;
@property (weak, nonatomic) IBOutlet UINavigationBar *navBarOut;
@property (weak, nonatomic) IBOutlet UIBarButtonItem *cancelButton;
@property (weak, nonatomic) IBOutlet UIBarButtonItem *doneButton;
- (IBAction)modalDone:(id)sender;
@end
设置视图控制器.m
#import "settingViewController.h"
#import <QuartzCore/QuartzCore.h>
@implementation settingViewController
@synthesize delegate;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
[[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:@"LightYopTexturedPaperWisoutBorder"] forBarMetrics:UIBarMetricsDefault];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return 2;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
NSString *CellIdentifier;
self.tableView.separatorColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"bg_stitch.png"]];
if(indexPath.row == 0) {
CellIdentifier = @"Name";
nameCell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
return nameCell;
} else {
CellIdentifier = @"Date";
dateCell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
return dateCell;
}
}
- (IBAction)modalDone:(id)sender {
[self.delegate modalDoneDel:self];
}
@end
左视图控制器.h
#import <UIKit/UIKit.h>
#import "JASidePanelController.h"
#import "UIViewController+JASidePanel.h"
#import "CoreData/CoreData.h"
#import "SetNameCell.h"
#import "SetDateCell.h"
#import "MenuCell.h"
#import "settingViewController.h"
#import "UIViewController+Alerts.h"
@interface leftViewController : UIViewController <UITableViewDataSource, UITableViewDelegate, settingViewDelegate> {
NSMutableArray *_items;
MenuCell *cell;
Boolean *addStar;
UIViewController *settingView;
UIView *currentView;
UIView *theWindow;
}
@property (readonly, strong, nonatomic) NSManagedObjectContext *managedObjectContext;
@property (readonly, strong, nonatomic) NSManagedObjectModel *managedObjectModel;
@property (readonly, strong, nonatomic) NSPersistentStoreCoordinator *persistentStoreCoordinator;
@property (strong, nonatomic) IBOutlet UIView *menuView;
- (IBAction)test:(id)sender;
- (IBAction)test1:(id)sender;
- (IBAction)editMenu:(id)sender;
@property (weak, nonatomic) IBOutlet UITableView *tableView;
@property (weak, nonatomic) IBOutlet UIButton *editButtonOut;
@property (strong, nonatomic) IBOutlet UIView *pickerView;
@property (weak, nonatomic) IBOutlet UIButton *addDoneOut;
@property (weak, nonatomic) IBOutlet UIView *footer;
@property (weak, nonatomic) IBOutlet UIButton *settingOut;
@property (weak, nonatomic) IBOutlet UIView *leftContView;
@end
左视图控制器.m
#import "leftViewController.h"
#import "QuartzCore/QuartzCore.h"
#define kModalSeguePushedBackAnimationDuration 0.3
#define kModalSegueBringForwardAnimationDuration 0.3
@interface leftViewController ()
@end
@implementation leftViewController
@synthesize managedObjectContext = _managedObjectContext;
@synthesize managedObjectModel = _managedObjectModel;
@synthesize persistentStoreCoordinator = _persistentStoreCoordinator;
- (void)viewDidLoad
{
[super viewDidLoad];
settingViewController *setingViewController = [[settingViewController alloc] init];
setingViewController.delegate = self;
_items = [[NSMutableArray alloc] init];
self.footer.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"LightYopTexturedPaperWisoutBorder"]];
_editButtonOut.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"LightBlueTexturedPaper.png"]];
_editButtonOut.layer.borderColor = [UIColor lightGrayColor].CGColor;
_editButtonOut.layer.borderWidth = 0.9f;
_editButtonOut.layer.cornerRadius = 5.0f;
_leftContView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"LightYopTexturedPaperWisoutBorder"]];
_leftContView.layer.cornerRadius = 5.0f;
_addDoneOut.hidden = YES;
}
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath
{
// The table view should not be re-orderable.
return YES;
}
-(void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)sourceIndexPath toIndexPath:(NSIndexPath *)destinationIndexPath {
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return 5;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
static NSString *CellIdentifier = @"Cell";
cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
UIView *bgview = [[UIView alloc] initWithFrame:CGRectZero];
bgview.backgroundColor =[UIColor colorWithPatternImage:[UIImage imageNamed:@"LightYopTexturedPaper"]];
cell.backgroundView = bgview;
UIView *bgviewselect = [[UIView alloc] initWithFrame:CGRectZero];
bgviewselect.backgroundColor =[UIColor colorWithPatternImage:[UIImage imageNamed:@"LightSelectTexturedPaper.png"]];
cell.selectedBackgroundView = bgviewselect;
self.tableView.backgroundColor =[UIColor colorWithPatternImage:[UIImage imageNamed:@"LightYopTexturedPaperWisoutBorder"]];
self.tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];
cell.menuLabel.highlightedTextColor = [UIColor whiteColor];
cell.manuImg.image = [UIImage imageNamed:@"moneybox.png"];
return cell;
}
- (IBAction)editMenu:(id)sender {
if(!self.tableView.editing){
[_editButtonOut setTitle:@"Done" forState:UIControlStateNormal];
[self.sidePanelController setCenterPanelHidden:YES animated:YES duration:0.2f];
[self.tableView setEditing: !self.tableView.editing animated:YES];
_settingOut.hidden = YES;
} else {
[_editButtonOut setTitle:@"Edit" forState:UIControlStateNormal];
[self.sidePanelController setCenterPanelHidden:NO animated:YES duration:0.2f];
[self.tableView setEditing: NO animated:YES];
_settingOut.hidden = NO;
}
}
-(UIImageView*)screenshotForView: (UIView*) view {
UIGraphicsBeginImageContextWithOptions(view.bounds.size, NO, [[UIScreen mainScreen] scale]);
[view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
if ([UIApplication sharedApplication].statusBarHidden == NO) {
CGFloat barHeight = [[UIApplication sharedApplication] statusBarFrame].size.height;
CGFloat scale = [[UIScreen mainScreen] scale];
CGRect rect = CGRectMake(0, barHeight * scale, view.bounds.size.width * scale, (view.bounds.size.height - barHeight) * scale);
CGImageRef imageRef = CGImageCreateWithImageInRect(image.CGImage, rect);
image = [UIImage imageWithCGImage:imageRef scale:image.scale orientation:image.imageOrientation];
}
UIImageView* screenshot = [[UIImageView alloc] initWithImage:image];
screenshot.frame = CGRectMake(0, 0, view.bounds.size.width, view.bounds.size.height);
screenshot.layer.cornerRadius = 5.0f;
screenshot.layer.masksToBounds = YES;
return screenshot;
}
-(CAAnimationGroup*)animationGroupPushedBackward {
CATransform3D t1 = CATransform3DIdentity;
t1.m34 = 1.0 / -900;
t1 = CATransform3DScale(t1, 0.90, 0.90, 1);
t1 = CATransform3DRotate(t1, 15.0f * M_PI/180.0f, 1, 0, 0);
CATransform3D t2 = CATransform3DIdentity;
t2.m34 = 1.0 / -900;
t2 = CATransform3DTranslate(t2, 0.0, -20.0, 0.0);
t2 = CATransform3DScale(t2, 0.85, 0.85, 1);
CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"transform"];
animation.toValue = [NSValue valueWithCATransform3D:t1];
animation.duration = 2 * kModalSeguePushedBackAnimationDuration / 3;
animation.fillMode = kCAFillModeForwards;
animation.removedOnCompletion = NO;
[animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn]];
CABasicAnimation *animation2 = [CABasicAnimation animationWithKeyPath:@"transform"];
animation2.toValue = [NSValue valueWithCATransform3D:t2];
animation2.beginTime = animation.duration;
animation2.duration = kModalSeguePushedBackAnimationDuration / 3;
animation2.fillMode = kCAFillModeForwards;
[animation2 setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn]];
animation2.removedOnCompletion = NO;
CAAnimationGroup *group = [CAAnimationGroup animation];
group.fillMode = kCAFillModeForwards;
group.removedOnCompletion = NO;
[group setDuration:animation.duration * 2];
[group setAnimations:[NSArray arrayWithObjects:animation,animation2, nil]];
return group;
}
-(CAAnimationGroup*)animationGroupBringForward {
CATransform3D t1 = CATransform3DIdentity;
t1.m34 = 1.0 / -900;
t1 = CATransform3DScale(t1, 0.90, 0.90, 1);
t1 = CATransform3DRotate(t1, 15.0f * M_PI/180.0f, 1, 0, 0);
CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"transform"];
animation.toValue = [NSValue valueWithCATransform3D:t1];
animation.duration = kModalSegueBringForwardAnimationDuration / 2;
animation.fillMode = kCAFillModeForwards;
animation.removedOnCompletion = NO;
[animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn]];
CABasicAnimation *animation2 = [CABasicAnimation animationWithKeyPath:@"transform"];
animation2.toValue = [NSValue valueWithCATransform3D:CATransform3DIdentity];
animation2.beginTime = animation.duration;
animation2.duration = kModalSegueBringForwardAnimationDuration / 2;
animation2.fillMode = kCAFillModeForwards;
[animation2 setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn]];
animation2.removedOnCompletion = NO;
CAAnimationGroup *group = [CAAnimationGroup animation];
group.fillMode = kCAFillModeForwards;
group.removedOnCompletion = NO;
[group setDuration:animation.duration * 2];
[group setAnimations:[NSArray arrayWithObjects:animation,animation2, nil]];
return group;
}
- (IBAction)test:(id)sender {
/* theWindow = [self.view superview];
[theWindow addSubview:settingView.view];
settingView.view.frame = CGRectMake(0, theWindow.frame.size.height, theWindow.frame.size.width, theWindow.frame.size.height);
[self.sidePanelController setCenterPanelHidden:YES animated:NO duration:0.0f];
[_leftContView.layer addAnimation:[self animationGroupPushedBackward] forKey:nil];
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.2f];
[UIView setAnimationCurve:UIViewAnimationCurveEaseIn];
settingView.view.frame = CGRectMake(0, 10, theWindow.frame.size.width, theWindow.frame.size.height);
[UIView commitAnimations]; */
//[self presentViewController:settingView animated:YES completion:nil];
[self.sidePanelController setCenterPanelHidden:YES animated:NO duration:0.0f];
[_leftContView.layer addAnimation:[self animationGroupPushedBackward] forKey:nil];
[self presentAlertViewController:[self.storyboard instantiateViewControllerWithIdentifier:@"addNewItem"] named:@"dd" animated:YES];
}
- (IBAction)test1:(id)sender {
[_leftContView.layer addAnimation:[self animationGroupBringForward] forKey:nil];
[self.sidePanelController setCenterPanelHidden:NO animated:NO duration:0.0f];
}
-(void)modalDoneDel:(settingViewController *)controller{
NSLog(@"ss");
[self.sidePanelController setCenterPanelHidden:NO animated:NO duration:0.0f];
}
@end