登录 立即注册
金钱:

Code4App-iOS开发-iOS 开源代码库-iOS代码实例搜索-iOS特效示例-iOS代码例子下载-Code4App.com

搜索按钮,搜索框

[复制链接]
来自: 206793787 分类: iOS精品源码 上传时间: 2016-4-13 11:35:40

项目介绍:

模仿格瓦拉电影搜索按钮使用方法:
[Objective-C] 查看源文件 复制代码
#import "ViewController.h"
#import "KSearchViewController.h"
#import "KSearchTransitioningAnimation.h"

@interface ViewController ()<UIViewControllerTransitioningDelegate,KSearchViewDelegate>

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    [self buildSearchButton];
}

- (void)buildSearchButton
{
    UIButton *searchButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 64 - 32, 64, 32)];
    searchButton.backgroundColor = [UIColor orangeColor];
    [searchButton setImage:[UIImage imageNamed:@"search"] forState:UIControlStateNormal];
    [self.view addSubview:searchButton];
    [searchButton addTarget:self action:@selector(searchOperation) forControlEvents:UIControlEventTouchUpInside];
    [self setButtonLayerMaskWithButton:searchButton];
}

- (void)setButtonLayerMaskWithButton:(UIButton *)searchButton
{
    CAShapeLayer *shapeLayer = [CAShapeLayer layer];
    UIBezierPath *path = [UIBezierPath bezierPath];
    [path moveToPoint:CGPointMake(0, 0)];
    CGFloat arcCenterX = searchButton.frame.size.width - searchButton.frame.size.height;
    CGFloat arcCenterY = searchButton.frame.size.height * 0.5;
    [path addLineToPoint:CGPointMake(arcCenterX, 0)];
    [path addArcWithCenter:CGPointMake(arcCenterX , arcCenterY) radius:arcCenterY startAngle: 3 * M_PI_2 endAngle: M_PI_2 clockwise:YES];
    [path addLineToPoint:CGPointMake(0, searchButton.frame.size.width)];
    shapeLayer.path = path.CGPath;
    searchButton.layer.mask = shapeLayer;

}

#pragma mark - SearchButtonAction
- (void)searchOperation
{
    KSearchViewController *searchVC = [[KSearchViewController alloc] init];
    searchVC.transitioningDelegate  = self;
    searchVC.delegate               = self;
    [self presentViewController:searchVC animated:YES completion:nil];
}

#pragma mark - UIViewControllerTransitioningDelegate
/**
 *  PresentAction
 */
- (id<UIViewControllerAnimatedTransitioning>)animationControllerForPresentedController:(UIViewController *)presented presentingController:(UIViewController *)presenting sourceController:(UIViewController *)source
{
    KSearchTransitioningAnimation *searchTransitionAnimation = [[KSearchTransitioningAnimation alloc] init];
    searchTransitionAnimation.isPresent                      = YES;
    return searchTransitionAnimation;
}

- (id<UIViewControllerAnimatedTransitioning>)animationControllerForDismissedController:(UIViewController *)dismissed
{
    KSearchTransitioningAnimation *searchTransitionAnimation = [[KSearchTransitioningAnimation alloc] init];
    searchTransitionAnimation.isPresent                      = NO;
    return searchTransitionAnimation;
}

#pragma mark - CancelButtonActionDelegate
- (void)ksearchViewCancelAction
{
    [self dismissViewControllerAnimated:YES completion:nil];
}

@end





相关源码推荐:

我来说两句
*滑动验证:
所有评论(45)
李世铿 2016-4-19 15:47:40
作者您好,您的50金钱已经充值到账,请注意查收哦,祝您玩得愉快~
回复
samatropos 2016-4-22 11:19:34
淡定,淡定,淡定……
回复
漫步沄端灬 2016-4-22 15:58:23
淡定,淡定,淡定……
回复
ak473548 2016-4-23 20:29:13
感谢分享,Code4App有你更精彩:)
回复
wys5311339 2016-4-27 16:53:12
感谢分享,Code4App有你更精彩:)
回复
帅气惊天 2016-4-28 15:23:19
精华内容,楼主V5!
回复
ZHAOBS 2016-4-29 09:26:19
很给力,Code4App有你更精彩!
回复
ogqs0493 2016-4-29 10:16:19
感谢分享,Code4App有你更精彩:)
回复
yonghuming_123 2016-5-3 19:13:49
正需要啊,感谢楼主无私分享!
回复
12345下一页
提取码:  下载次数:66 状态:已购或VIP 售价:0(原价:5)金钱 下载权限:初级码农 
1775 0 66
联系我们
首页/微信公众账号投稿

帖子代码编辑/版权问题

QQ:435399051,742864542

如何获得代码达人称号?

代码贡献英雄榜
用户名 下载数
通过邮件订阅最新 Code4App 信息
上一条 /4 下一条
联系我们
关闭
合作电话:
13802416937
Email:
435399051@qq.com
商务市场合作/投稿
问题反馈及帮助
联系我们

广告投放| 广东互联网违法和不良信息举报中心|中国互联网举报中心|Github|申请友链|手机版|Code4App ( 粤ICP备15117877号-1 )

快速回复 返回顶部 返回列表