• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

wimagguc/ios-custom-alertview: Custom UIAlertView. Continue adding images and UI ...

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称:

wimagguc/ios-custom-alertview

开源软件地址:

https://github.com/wimagguc/ios-custom-alertview

开源编程语言:

Objective-C 95.4%

开源软件介绍:

Custom iOS AlertView

v0.9.5

support for iOS7+

The addSubview is not available in UIAlertView since iOS7. The view hierarchy for this class is private and must not be modified.

As a solution, this class creates an iOS-style dialog which you can extend with any UIViews or buttons. The animations and the looks are copied too and no images or other resources are needed.

A demo screen

Install

As simple as adding the following files to your project:

  • CustomIOSAlertView.h
  • CustomIOSAlertView.m

Or use Cocoapods:

pod 'CustomIOSAlertView', '~> 0.9.5'

Change notes

  • Fixed rotation for IOS8

  • Removed 7 from the class name. Just use CustomIOSAlertView from now on, like: [[CustomIOSAlertView alloc] init];

  • The initWithParentView method is now deprecated. Please use the init method instead, where you don't need to pass a parent view at all. In case the init doesn't work for you, please leave a note or open an issue here.

Quick start guide

  1. Create the UIView object changed

    CustomIOSAlertView *alertView = [[CustomIOSAlertView alloc] init];
    
  2. Add some custom content to the alert view (optional)

    UIView *customView ..;
    
    [alertView setContainerView:customView];
    
  3. Display the dialog

    [alertView show];
    

More functions

  • Close the dialog

    [alertView close];
    
  • To add more buttons, pass a list of titles

    [alertView setButtonTitles:[NSMutableArray arrayWithObjects:@"Button1", @"Button2", @"Button3", nil]];
    
  • You can remove all buttons by passing nil

    [alertView setButtonTitles:NULL];
    
  • You can enable or disable the iOS7 parallax effects on the alert view

    [alertView setUseMotionEffects:TRUE];
    
  • Handle button clicks with a custom delegate

    First, set the delegate:

    [alertView setDelegate:self];
    

    Then add the delegate methods:

    - (void)customIOS7dialogButtonTouchUpInside: (CustomIOSAlertView *)alertView clickedButtonAtIndex: (NSInteger)buttonIndex
    {
        NSLog(@"Button at position %d is clicked on alertView %d.", buttonIndex, [alertView tag]);
    }
    
  • Handle button clicks with a code block

    [alertView setOnButtonTouchUpInside:^(CustomIOSAlertView *alertView, int buttonIndex) {
        NSLog(@"Block: Button at position %d is clicked on alertView %d.", buttonIndex, [alertView tag]);
        [alertView close];
    }];
    

    You can also disable all other delegates by:

[alertView setDelegate:self]; ```

Todos

This is a really quick implementation, and there are a few things missing:

  • Adding more buttons: they don't exactly match the look with that of on iOS7

  • Rotation: rotates wrong with the keyboard on

Special thanks to

  • @tamasdancsi for his support with the initial code
  • @dingosky for his work on the parallax effects code
  • @raspu for his work on the protocol delegates, iOS6 support and onButtonClick blocks
  • @sbandol for his idea on adding the AlertView as the top most view in the hierarchy
  • @scorpiozj for his work on the rotation code
  • @kwent for adding performance optimisations
  • @thomasaw for the refract on the deprecated initWithParentview
  • @yiboyu for the multi-line button fix
  • @logicxd for the close-on-touchup-outside code

License

MIT. Please read LICENSE.md for more info.

Other projects

Check out Appwoodoo for push notifications and remote app control service. Open source SDKs are available on Github: github.com/appwoodoo.

Some more of my free stuff for web devs at Github.

Project updates newsletter

About

Richard Dancsi
www.wimagguc.com

twitter: @wimagguc
linkedin: linkedin.com/in/richarddancsi




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap