app页面切换特效app 怎么实现和如何把代码放到那一部分里

快速实现APP中的设置界面效果
查看次数:5330
下载次数:1282
上传时间:
大小:485 B
快速实现APP中的设置界面效果 
测试环境:Xcode 7.0,iOS 7.0 以上
  
集成步骤:
0、把TableViewSettingList文件夹拽入自己项目中
1、新建一个UITableViewController继承自CFSettingTableViewController
2、相关代码
// cell箭头名称
self.icon_arrow = @"CellArrow";
// 设置相关参数
// cell背景颜色
//self.backgroundColor_Normal = [UIColor whiteColor];
//cell选中背景颜色
// self.backgroundColor_Selected = CFCellBackgroundColor_H
//cell右边Label字体
// self.rightLabelFont = [UIFont systemFontOfSize:15];
//cell右边Label文字颜色
// self.rightLabelFontColor = CFRightLabelTextC
CFSettingArrowItem *item1 =[CFSettingArrowItem itemWithIcon:@"icon1" title:@"朋友圈" destVcClass:[Item1ViewController class]];
CFSettingGroup *group1 = [[CFSettingGroup alloc] init];
group1.items = @[ item1];
CFSettingArrowItem *item2 =[CFSettingArrowItem itemWithIcon:@"icon2" title:@"扫一扫" destVcClass:[Item1ViewController class]];
CFSettingArrowItem *item3 =[CFSettingArrowItem itemWithIcon:@"icon3" title:@"摇一摇"];
__weak typeof(self) weakSelf =
item3.opration = ^{
    Item1ViewController *vc = [[Item1ViewController alloc]init];
    [weakSelf.navigationController pushViewController:vc animated:YES];
CFSettingGroup *group2 = [[CFSettingGroup alloc] init];
group2.items = @[ item2,item3 ];
CFSettingIconArrowItem *item4 =[CFSettingIconArrowItem itemWithIcon:@"icon4" title:@"附近的人" destVcClass:[Item1ViewController class]];
item4.icon_right = @"FootStep";
CFSettingGroup *group3 = [[CFSettingGroup alloc] init];
group3.items = @[ item4];
group3.header = @"头部文本";
group3.footer = @"底部文本";
group3.headerHeight = 30;
group3.footerHeight = 30;
CFSettingLabelArrowItem *item5 =[CFSettingLabelArrowItem itemWithIcon:@"icon2" title:@"扫一扫" destVcClass:[Item1ViewController class]];
item5.text_right = @"扫一扫扫一扫";
CFSettingLabelItem *item6 =[CFSettingLabelItem itemWithIcon:@"icon3" title:@"摇一摇"];
item6.text_right = @"摇一摇摇一摇";
CFSettingGroup *group4 = [[CFSettingGroup alloc] init];
group4.items = @[ item5,item6 ];
CFSettingSwitchItem *item7 =[CFSettingSwitchItem itemWithIcon:@"icon3" title:@"账号保护"];
// 用户第一次设置前  默认打开开关
item7.defaultOn = YES;
// 开关状态改变时执行的操作
item7.opration_switch = ^(BOOL isON){
    CFLog(@"UISwitch状态改变 %d",isON);
BOOL isON = [CFSettingSwitchItem isONSwitchByTitle:item7.title];
CFLog(@"是否打开了开关 %d",isON);
CFSettingGroup *group5 = [[CFSettingGroup alloc] init];
group5.items = @[ item7 ];
CFSettingIconItem *item8 =[CFSettingIconItem itemWithIcon:@"icon3" title:@"右边头像"];
item8.cellHeight = 60;
item8.icon_right =@"icon_touxiang";
CFSettingGroup *group6 = [[CFSettingGroup alloc] init];
group6.items = @[ item8 ];
[self.dataList addObject:group1];
[self.dataList addObject:group2];
[self.dataList addObject:group3];
[self.dataList addObject:group4];
[self.dataList addObject:group5];
[self.dataList addObject:group6];
您还没有登录!请或
下载过该代码的还下载了
本周热门下载
&2017 Chukong Technologies,Inc.
京公网安备89258被浏览7382分享邀请回答activityRecord{43e5f588 u0 com.zhihu.android/.ui.activity.MainActivity t10}
Intent { cmp=com.zhihu.android/.ui.activity.MainActivity (has extras) }
ProcessRecord{4415c458 21049:com.zhihu.android/u0a162}
TaskRecord{43c0e5a0 #10 A=com.zhihu.android U=0 sz=3}
Run #5: ActivityRecord{ u0 com.zhihu.android/.ui.activity.AnswersViewerActivity t10}
Run #4: ActivityRecord{4368cd28 u0 com.zhihu.android/.ui.activity.QuestionViewerActivity t10}
Run #3: ActivityRecord{43e5f588 u0 com.zhihu.android/.ui.activity.MainActivity t10}
mResumedActivity: ActivityRecord{ u0 com.zhihu.android/.ui.activity.AnswersViewerActivity t10}
mFocusedActivity: ActivityRecord{ u0 com.zhihu.android/.ui.activity.AnswersViewerActivity t10}
* Recent #0: TaskRecord{43c0e5a0 #10 A=com.zhihu.android U=0 sz=3}
多试几次,可以得出结论,是activity组成。(命名不错!)再上一图可以看出是就是一滑动的viewgroup,里面放置一content view。然后将activity设置为透明背景,就能看到上一个activity的内容。可以看出是就是一滑动的viewgroup,里面放置一content view。然后将activity设置为透明背景,就能看到上一个activity的内容。好巧!!!我也是改的SlidingPaneLayout实现的。去掉原本的滑动透明效果和改下边距即可, 再改下可以只边缘滑动。 2年前知乎是用的SlidingMenu实现的,参照我之前的回答当然DrawerLayout改下也可以,不过没有判断x/y的权重,只适合边缘滑动。github上的的这个其实就是DrawerLayout改了下。几个月前看lbe也用的这个。当然Fragment实现更简单了,直接popback一个滑动的布局即可。比如微信(在我的5.x上的nexus4测试机上)会出滑动效果,而且上一个视图也会滑动(这一点Activity无法办到)。 补充前面Fragment泛指视图管理者。微信应该是2种方式都用了。有人反馈说activity设置透明背景,会导致onStop不会被调用。翻阅了一下Activity的代码,onStop没有太多工作量。然后尝试把自己的程序不断打开新界面(透明activity方式),到后面越来越卡,直到崩溃。与绘制相关的异常(忘记截图)。原因我估计是设置activity透明,会导致系统在绘制的时候,会将栈里面的每一个Activity绘制一遍,而非透明的Activity。只用绘制当前Activity的内容。所以这算是一副作用,对于会进栈很深的程序。(知乎也会很卡,开多了页面)。本来想试下微信的,无奈点了半天,才发现几个页面是SingleTask的,返回几下,就回到主页面了(囧)。这里再提供一种实现方式,使用普通的Activity(不透明)。在要打开新Activity的时候,截取当前Activity保存到磁盘里。在新Activity中取出来设置为SlidingBack的左侧ImageView的图片。效果也出来了,并且还能做类似IOS视觉差效果(也就是微信非Activity那种)。难点在于要自己管理多个Activity的截图的缓存,变好号。这里上代码,刚写的(没做多个Activity截图管理)/** 打开下载 */
public static void openDownload(Context context) {
Activity ac = (Activity)
Bitmap bitmap = getActivityBitmap(ac);
AppCache.getCache().put("LastActivtyBitmap", bitmap);
MobclickAgent.onEvent(context, "openDownload");
HostActivity.startFragment(context, DownloadFragment.class);
新Activity中视图的处理这样也能达到类似的效果,不过滑动出来的“旧Activity”无法刷新,毕竟只是一张截图。(ps:这段代码也做了透明状态栏处理)。这样也能达到类似的效果,不过滑动出来的“旧Activity”无法刷新,毕竟只是一张截图。(ps:这段代码也做了透明状态栏处理)。有个问题顺便问下,我在Activity的style里设置了无动画,但最终还是会闪一下。只有代码里加了overridePendingTransition(0, 0);才会完全没动画,不知道什么原因....12416 条评论分享收藏感谢收起0添加评论分享收藏感谢收起查看更多回答jQuery实现切换页面过渡动画效果
投稿:lijiao
字体:[ ] 类型:转载 时间:
这是一款效果非常酷的jQuery和CSS3通过AJAX调用切换页面过渡动画特效插件。该页面切换特效使用AJAX来动态加载链接内容,在页面加载的时候,使用CSS3来制作非常酷的页面过渡动画效果。插件中使用pushState方法来管理浏览器的浏览历史,需要的朋友可以参考下
直接为大家介绍制作过程,希望大家可以喜欢。
该页面切换特效的HTML结构使用一个&main&元素来作为页面的包裹元素,div.cd-cover-layer用于制作页面切换时的遮罩层,div.cd-loading-bar是进行ajax加载时的loading进度条。
&div class="cd-index cd-main-content"&
&h1&Page Transition&/h1&
&!-- your content here --&
&div class="cd-cover-layer"&&/div& &!-- this is the cover layer --&
&div class="cd-loading-bar"&&/div& &!-- this is the loading bar --&
该页面切换特效中使用body::before和body::after伪元素在页面切换过程中创建两个遮罩层来遮住页面内容。它们的定位是固定定位,高度等于50vh,宽度为100%。默认情况下,使用CSS transform属性将它们隐藏起来(translateY(-100%)/translateY(100%))。当用户切换页面的时候,这些元素被移动回视口当中(通过在&body&元素上添加.page-is-changing class)。
下面的图片演示了这个过程:
页面切换特效
body::after, body::before {
/* these are the 2 half blocks which cover the content once the animation is triggered */
height: 50
width: 100%;
body::before {
transform: translateY(-100%);
body::after {
bottom: 0;
transform: translateY(100%);
body.page-is-changing::after, body.page-is-changing::before {
transform: translateY(0);
页面切换时,页面内容的淡入淡出效果是通过改变div.cd-cover-layer的透明度实现的。它覆盖了.cd-main-content元素,并具有相同的背景色,然后在&body&被添加.page-is-changing class的时候,将透明度从0修改为1。
Loading进度条使用.cd-loading-bar::before伪元素来制作。默认它被缩小(scaleX(0))和transform-origin: left center。当页面切换开始时它被使用scaleX(1)放大会原来的尺寸。
.cd-loading-bar {
/* this is the loading bar - visible while switching from one page to the following one */
width: 90%;
.cd-loading-bar::before {
/* this is the progress bar inside the loading bar */
height: 100%;
width: 100%;
transform: scaleX(0);
transform-origin:
.page-is-changing .cd-loading-bar::before {
transform: scaleX(1);
特效中平滑的过渡效果使用CSS Transitions来实现。每一个动画元素都被添加了不同的transition-delay,以实现不同的元素动画顺序。
&JAVASCRIPT
该页面切换特效中在链接上使用data-type="page-transition"属性,用于触发页面切换事件。当插件检测到用户点击事件,changePage()方法将被执行。
$('main').on('click', '[data-type="page-transition"]', function(event){
event.preventDefault();
//detect which page has been selected
var newPage = $(this).attr('href');
//if the page is not animating - trigger animation
if( !isAnimating ) changePage(newPage, true);
这个方法会触发页面切换动画,并通过loadNewContent()方法加载新内容。
function changePage(url, bool) {
isAnimating =
// trigger page animation
$('body').addClass('page-is-changing');
loadNewContent(url, bool);
当新的内容被加载后,会替代原来&main&元素中的内容。.page-is-changing class被从body中移除,新加载的内容会被添加到window.history中(使用pushState()方法)。
function loadNewContent(url, bool) {
var newSectionName = 'cd-'+url.replace('.html', ''),
section = $('&div class="cd-main-content '+newSectionName+'"&&/div&');
section.load(url+' .cd-main-content & *', function(event){
// load new content and replace &main& content with the new one
$('main').html(section);
$('body').removeClass('page-is-changing');
if(url != window.location){
//add the new page to the window.history
window.history.pushState({path: url},'',url);
为了在用户点击浏览器的回退按钮时触发相同的页面切换动画效果,插件中监听popstate事件,并在它触发时执行changePage()函数。
$(window).on('popstate', function() {
var newPageArray = location.pathname.split('/'),
//this is the url of the page to be loaded
newPage = newPageArray[newPageArray.length - 1];
if( !isAnimating ) changePage(newPage);
您可能感兴趣的文章:
大家感兴趣的内容
12345678910
最近更新的内容
常用在线小工具iOS / iPhone 实现各种页面过渡切换效果 代码 常用16种视图切换动画 视图切换(View Transition)开源代码 -
常用16种视图切换动画
已有 498 人收藏
&&&&实现各种页面过渡切换效果。前4种是UIView,后面都是 Core Animation。
&&&&下面8种是传说中的私有API(作者测试过,能通过审核,请放心使用)。所有效果整合到一个例子里,代码较清晰,适合新手阅读。
&&&&小编注:感谢开发者@iimgal 分享代码于Code4App。
测试环境:
&&[Code4App]编译测试
相关代码:
(14229次查看,2378次下载)
(13728次查看,3208次下载)
(14505次查看,1554次下载)
(32978次查看,9523次下载)
(20358次查看,4577次下载)
(16926次查看,3923次下载)
(18478次查看,3157次下载)
(33439次查看,7318次下载)
(26736次查看,7213次下载)
(26514次查看,4187次下载)
代码评论:
登录后方可评论
这个真的好厉害
登录后方可评论
登录后方可评论
这个真的顶你,谢谢兄弟!
登录后方可评论
很好很强大 赞一个
登录后方可评论
很好很强大!
登录后方可评论
登录后方可评论
不支持转屏啊,转屏后方向不对,怎么解决
登录后方可评论
-控件分类-
-功能分类-}

我要回帖

更多关于 app切换国家 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信