1,actionsheet动作选择面板 index.wxml: 小程序弹出actionsheet选择面板的方法有点怪异,是控制一个预定义好的actionsheet的hidden属性实现的。 2,toast小提示弹窗 与actionsheet相同,也是预定义好,然后控制它的hidden属性。同样不需要关心位置,默认在屏幕中音弹出来。 这一点与actionsheet相似,后者是在单击了取消项,或者单击了背景了之后触发。都是控制hidden的主动权交给了程序员。
但有的时候,交互提给我们的需求又需要我们的ActionSheet具有图文混排的效果,那就需要我们自己仿造系统自带的ActionSheet,完成该需求。 ,所以在当前Controller需要实现以下代理方法: -(void) didSelectIndex:(NSInteger)index{ } 该代理方法,主要是在Controller中能够实现在自定义ActionSheet 三、实现原理 因为ActionSheet不能支持图片的显示,所以我们就放弃使用扩展UIActionSheet控件的方法。 我在本项目中使用的是UITableView+动画,高仿ActionSheet的方法。UTableView可以制作列表选项,动画可以实现系统自带ActionSheet的自底向上和渐变效果。 该扩展的ActionSheet也可以用于以下场景: 3.gif 4.gif 五、下载地址 Demo下载地址:这是一个我的iOS交流圈:624212887,群文件自行下载,不管你是小白还是大牛热烈欢迎进群
动作表单(ActionSheet) iOS程序员一定对ActionSheet非常熟悉,这是Cocoa Touch很常用的UI组件。 图1 ActionSheet的效果 图1是小程序ActionSheet的效果,与iOS ActionSheet的效果类似。 在小程序中使用ActionSheet要使用<action-sheet>标签,该标签中可以包含任意的组件,因此,可以在ActionSheet上放置任何小程序支持的UI元素。 通过<action-sheet>标签的hidden属性可以控制ActionSheet的显示和隐藏,该属性值为true,表示隐藏ActionSheet,为false,表示显示ActionSheet。 通过bindchange属性指定一个事件函数,当点击“取消”按钮或ActionSheet外部区域,会调用该函数,通常在该函数中隐藏ActionSheet。 下面是完整的JavaScript实现代码。
:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex { NSLog(@"%ld",buttonIndex :(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex { NSLog(@"%ld",buttonIndex :(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex { NSLog(@"%ld",buttonIndex loginAndPwdTextAlert.gif (二)UIActionSheet - (void)actionSheet { // iOS8被废弃 UIActionSheet *sheet actionSheet.gif (三)UIAlertController UIAlertController从iOS8.0开始被使用。
dismissWithClickedButtonIndex:(NSInteger)buttonIndex animated:(BOOL)animated; 使用代码将视图收回 三、UIActionSheet代理方法 - (void)actionSheet :(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex; 点击按钮时触发的方法 - (void)willPresentActionSheet :(UIActionSheet *)actionSheet; 视图将要弹出时触发的方法 - (void)didPresentActionSheet:(UIActionSheet *)actionSheet ; 视图已经弹出式触发的方法 - (void)actionSheet:(UIActionSheet *)actionSheet willDismissWithButtonIndex:(NSInteger )buttonIndex; 点击按钮后,视图将要收回时触发的方法 - (void)actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex
首先我们storyboard 创建一个button 用于触发选择事件 @IBAction func selectImageAction(sender: AnyObject) { } 这时候通常会弹出来一个ActionSheet iOS 8 以后actionsheet 和 alertview 都统一用UIAlertController 方法调用,8.3以前actionsheet 有独立的方法 后来都废弃了。 首先我们要加入actionsheet 相关delegate 如下 class ViewController: UIViewController ,UIImagePickerControllerDelegate actionSheetController: UIAlertController = UIAlertController(title: "请选择", message:nil, preferredStyle: .ActionSheet moviePictureAction) self.presentViewController(actionSheetController, animated: true, completion: nil) } 这样我们想要的actionSheet
from 'vux/src/components/actionsheet' /** * 官网有一些 bug * 按照官方文档提示在项目入口文件中 全局注册 并不成功 * import Vue from 'vue' * import { Actionsheet } from 'vux' * Vue.component('actionsheet', Actionsheet) * * 把import { Actionsheet } from 'vux' 改成 * import Actionsheet from 'vux/src/components/actionsheet' 即可 * * 但是局部注册却有效 * import { Actionsheet } from 'vux' * export default { * components: { * Actionsheet * } * } * * actionsheet 用法有些问题 * <group> * <x-switch title="demo" v-model="show1"></x-switch> * </group
UILongPressGestureRecognizer*)gesture { if(gesture.state == UIGestureRecognizerStateBegan) { UIActionSheet *actionSheet delegate:self cancelButtonTitle:@"取消"destructiveButtonTitle:nil otherButtonTitles:@"保存图片",nil]; actionSheet.actionSheetStyle = UIActionSheetStyleBlackOpaque; [actionSheet showInView:self.view]; UIImageView = imgView.image; } } 实现UIActionSheetDelegate代理方法 #pragma - mark - UIActionSheetDelegate - (void)actionSheet :(UIActionSheet*)actionSheet didDismissWithButtonIndex: (NSInteger)buttonIndex { if(buttonIndex
组件也支持通过插槽来定制部分内容,支持的插槽如下: 插槽名 意义 title 组件标题区域插槽 desc 组件内容描述区域插槽 footer 组件尾部区域插槽 3.ActionSheet 抽屉视图组件 ActionSheet 组件是一种与 HalfScreenDialog 类似的弹窗,都是从页面底部向上弹出,适用于用户从一组选项中进行选择的场景。 引入路径: 'weui-miniprogram/actionsheet/actionsheet' 示例代码: 在 WXML 页面文件中,可以编写如下示例代码来使用 ActionSheet 组件: <mp-actionSheet actions="{{[{text: '第一项', type: 'default'}, {text: '第二项', type: 'default'}]}}" title="弹窗标题"> </mp-actionSheet ActionSheet 组件可设置的属性 属性名 类型 意义 title 字符串
-- ActionSheet进出动画 --> <style name="ActionSheetDialogAnimation" parent="@android:style/Animation.Dialog "> <item name="android:windowEnterAnimation">@anim/actionsheet_dialog_in</item> <item name="android:windowExitAnimation">@anim/actionsheet_dialog_out</item> </style> 进出动画 actionsheet_dialog_in.xml apk/res/android" android:duration="200" android:fromYDelta="100%" android:toYDelta="0" /> actionsheet_dialog_out.xml
space-between;">
VPopup自定义弹窗 一个汇聚了Vant及NutUI中的 Msg信息框、Popup弹出层、Notify通知信息、Dialog对话框、ActionSheet动作面板框及Toast弱提示框 等功能。 image.png 提供了基本的 Msg 信息框、ActionSheet 底部面板框、Android/IOS 弹窗风格、Toast 弱提示框。支持上 /下 /左 /右弹出层,右键 /长按弹窗。 -- ActionSheet底部菜单 --> <v-popup v-model="showActionSheet" anim="footer" type="<em>actionsheet</em>" :z-index=" --- v-model 当前组件是否显示 title 标题 content 内容(支持自定义插槽内容) type 弹窗类型(toast | footer | <em>actionsheet</em>
Category 用Category来分离业务时,在Category使用了ActionSheet。 如果对应的ViewController也实现了- (void)actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger
内置所有的弹层类组件都是基于此组件实现,包括:Toast、Picker、TimePicker、Dialog、ActionSheet。 ActionSheet:ActionSheet操作列表提供了两种常见的样式,灵活可控内容。
rac_delegateProxy跟之前textview是一样的用法这里开始就不再解释这类属性了 我们直接试着使用rac_buttonClickedSignal UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"RAC ActionSheet" delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:@"OK" otherButtonTitles:@"Other", nil]; [[actionSheet rac_buttonClickedSignal subscribeNext:^(NSNumber * _Nullable x) { NSLog(@"%@", x); }]; [actionSheet showInView:self.view]; 运行看看, x是actionSheet上按钮的编号, 我们拿到编号就可以做响应的事件处理了.
ActionSheetPicker-3.0 - 该项目是此前热门项目ActionSheetPicker的新版本,快速复制了iOS 8上的下拉UIPickerView / ActionSheet功能。 CCActionSheet - CCActionSheet:仿照微信朋友圈自定义actionsheet,一行代码即可使用。 TBActionSheet.swift - 支持Carthage,可自定义度100%的ActionSheet,支持微信样式。
AlertController, public imagePicker: ImagePicker, public camera: Camera) { } presentActionSheet() { let actionSheet 'cancel', handler: () => { console.log("cancel"); } }] }); actionSheet.present
包含button、cell、dialog、 progress、 toast、article、actionsheet、icon等各式元素。 02 — ? ? ? ? ? ? ? ? ?
"]; sheet.lineColor = [UIColor colorWithHexString:@"dbdce4"]; [sheet show]; } - (void)actionSheet :(FMActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex{ if (buttonIndex == 0) cancelButtonTitle:nil otherButtonTitles:@"确定", nil]; [alert show]; } } - (UIColor *)actionSheet :(FMActionSheet *)actionSheet buttonTextColorAtIndex:(NSInteger)bottonIndex{ UIColor *textColor =