CAGradientLayer *gradient = [CAGradientLayer layer];
gradient.frame = button.bounds;
gradient.colors = [NSArray arrayWithObjects:
(id)[UIColor colorWithRed:255/255.0f green:254/255.0f blue:249/255.0f alpha:1.0f].CGColor,
(id)[UIColor colorWithRed:250/255.0f green:240/255.0f blue:203/255.0f alpha:1.0f].CGColor,
nil];
[button.layer insertSublayer:gradient atIndex:0];
NSString *urlString = [NSString stringWithFormat:@"http://****?page=%d",page];
NSURL *url = [NSURL URLWithString:urlString];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:YES];
AFJSONRequestOperation *operation = [AFJSONRequestOperation JSONRequestOperationWithRequest:request success:^(NSURLRequest *request, NSHTTPURLResponse *response, id JSON) {
if([JSON objectForKey:@"success"]){
// books = [NSMutableArray arrayWithCapacity:20];
for (id key in [JSON objectForKey:@"data"]){
}
//状态栏的菊花
[[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:NO];
[self.tableView reloadData];
}else{
NSLog(@"load error: %@", [JSON objectForKey:@"info"]);
}
} failure:^(NSURLRequest *request , NSURLResponse *response , NSError *error , id JSON){
[[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:NO];
}];
[operation start];
UIStoryboard * storyboard = self.storyboard;
BookDetailViewController *detailViewController = [storyboard instantiateViewControllerWithIdentifier:@"bookdetail"] ; // ...
// Pass the selected object to the new view controller.
Book *book=[self.books objectAtIndex:indexPath.row];
detailViewController.book=book;
[self.navigationController pushViewController:detailViewController animated:YES];
detailViewController=nil;
- (void) hideTabBar:(BOOL) hidden{
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.5];
for(UIView *view in self.tabBarController.view.subviews)
{
if([view isKindOfClass:[UITabBar class]])
{
if (hidden) {
[view setFrame:CGRectMake(view.frame.origin.x, 480, view.frame.size.width, view.frame.size.height)];
} else {
[view setFrame:CGRectMake(view.frame.origin.x, 480-49, view.frame.size.width, view.frame.size.height)];
}
}
else
{
if (hidden) {
[view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, 480)];
} else {
[view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, 480-49)];
}
}
}
[UIView commitAnimations];
}
-(void)hideTabbarTimeSelector
{
[self hideTabBar:YES];
}
[self.navigationController pushViewController:detailViewController animated:YES];
[self performSelector:@selector(hideTabbarTimeSelector) withObject:nil afterDelay:0.3];
NSUserDefaults * userDefault = [NSUserDefaults standardUserDefaults];
[userDefault setObject:username forKey:@"username"];
[userDefault setObject:password forKey:@"password"];
[[NSUserDefaults standardUserDefaults] synchronize];
NSLog(@"写入用户信息:%@", userDefault);