- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我想做一个从日历放大的动画,特别是原点和帧大小是委托(delegate)今天日期的按钮的大小。下面是用于确定 CalendarMonthView.m 中的 todayButton 的代码:
NSDate *date = (weekdayOffset > 0) ? [_monthStartDate dateByAddingTimeInterval:-1 * weekdayOffset * D_DAY] : _monthStartDate;
BOOL bEnabled = (weekdayOffset == 0);
CGRect buttonFrame = CGRectMake (0, 0, 81, 61);
int idx = -1 * weekdayOffset;
for (int y = 0; y < 6; y++) {
buttonFrame.origin.x = 0;
for (int x = 0; x < 7; x++) {
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
button.tag = idx++;
[button setFrame:buttonFrame];
[button setBackgroundImage:[UIImage imageNamed:@"calendarFlyout_dayContainer_today.png"] forState:UIControlStateSelected];
[button setBackgroundImage:[UIImage imageNamed:@"calendarFlyout_selected.png"] forState:UIControlStateHighlighted];
button.titleLabel.font = [UIFont fontWithName:@"TitilliumWeb-Regular" size:18.0];
button.titleLabel.textAlignment = NSTextAlignmentCenter;
// TODO: optimize performance
int dayOfMonth = (int)[_calendar component:NSCalendarUnitDay fromDate:date];
if (dayOfMonth < prevDayOfMonth) {
bEnabled = !bEnabled;
}
prevDayOfMonth = dayOfMonth;
[button setTitle:[NSString stringWithFormat:@"%d", dayOfMonth] forState:UIControlStateNormal];
[button setTitleColor:[UIColor darkGrayColor] forState:UIControlStateNormal];
[button setTitleColor:[UIColor lightGrayColor] forState:UIControlStateDisabled];
[button setTitleColor:[UIColor whiteColor] forState:UIControlStateHighlighted];
[button setTitleColor:[UIColor whiteColor] forState:UIControlStateSelected];
[button setBackgroundImage:[UIImage imageNamed:((bEnabled) ? @"calendarFlyout_dayContainer_insideMonth.png"
: @"calendarFlyout_dayContainer_outsideMonth.png")]
forState:UIControlStateNormal];
// button.enabled = bEnabled;
button.selected = [date isToday];
if (button.selected == NO) {
button.highlighted = (_currentDayDate) ? [date isEqualToDateIgnoringTime:_currentDayDate] : NO;
} else {
// Set buttonHolder to today
}
[button addTarget:self action:@selector (dayButtonTapped:) forControlEvents:UIControlEventTouchUpInside];
[_dayButtonsHolderView addSubview:button];
buttonFrame.origin.x += buttonFrame.size.width;
date = [date dateByAddingTimeInterval:D_DAY];
}
buttonFrame.origin.y += buttonFrame.size.height;
}
- (IBAction)dayButtonTapped:(id)sender
{
if (_delegate) {
UIButton *button = (UIButton *)sender;
NSDate *selectedDate = [_monthStartDate dateByAddingDays:button.tag];
[_delegate performSelector:@selector (calendarMonthView:dateSelected:) withObject:self withObject:selectedDate];
}
}
我想获取 button
的框架,并在 CalendarFlyoutView.m 中使用的动画中使用它。
我是 iOS 编程的新手,我阅读了一些委托(delegate)信息并通过 segues 传递信息,但这似乎对我没有帮助。
如有任何帮助,我们将不胜感激。
最佳答案
使用转换
功能。
//在年历中设置动画 _yearCalendarView.hidden = NO; self.curMonthView.monthLabel.hidden = YES;
CalendarMonthView *monthView = [CalendarMonthView new];
monthView.delegate = self;
CGRect buttonFrame = _currentDayButtonFrame;
_yearCalendarView.frame = CGRectMake(buttonFrame.origin.x, buttonFrame.origin.y + buttonFrame.size.height, buttonFrame.size.width, buttonFrame.size.height);
NSLog(@"_yearCalendarView frame: %@", NSStringFromCGRect(_yearCalendarView.frame));
_yearCalendarView.transform = CGAffineTransformMakeScale(0.01, 0.01);
[UIView animateWithDuration:kAnimation_ExpandCalendarDuration delay:0 options:UIViewAnimationOptionCurveEaseOut animations:^{
_yearCalendarView.transform = CGAffineTransformIdentity;
_yearCalendarView.frame = CGRectMake(_monthSwiperScrollView.frame.origin.x, _monthBarImageView.frame.size.height + 20, _monthSwiperScrollView.frame.size.width + 2, _yearFlyoutHeight);
} completion:^(BOOL finished) {
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector (yearCalendarAnimationDidStop:finished:context:)];
}];
关于ios - 如何在 ViewController 之间传递 UIButton 的框架和原点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32488101/
我试图弄清楚如何获取所有可见窗口的框架。我尝试了以下代码,但它仅适用于应用程序本身,其他窗口报告 {0,0,0,0} NSArray *windowArray = [NSWindow wind
左矩形=新矩形(0,0,WIDTH/9,HEIGHT);在此代码中,如果我增加宽度,为什么它看起来会进一步延伸到 JFrame 的左侧?如果我减少它为什么它会向右延伸?这不是像坐标平原一样工作吗?高度
假设我有一个 AffineTransform (transform) 并调用它的一堆方法。假设我旋转并平移它。然后我用它转换图形对象 (g2d): g2d.transform(transform);
我认为当你对物体施加力时,它会施加到 body 的原点(可能是质心)。现在我正在尝试创建类似俄罗斯方 block 的 block ,并通过应用 LinearPulse 使它们跳跃,如下所示: body
我正在阅读 Big Nerd Ranch 指南第 4 版,但在处理 View 和 View 层次结构的章节中,我遇到了一些与 View 来源有关的问题。 我已经在我的 View Controller
我想把原点放在中心,所以我做了: SetViewportOrgEx(hdc,width/2,height/2,NULL); (如下面的代码所示) 现在,在实现双缓冲后它似乎无法正常工作。任何想法为什么
当我的 Sprite 旋转原点固定在窗口的左上角时,我遇到了这个问题(与 sprite.Draw 和 sprite.Draw2D 相同)无论哪种方式,如果我改变旋转中心它仍然在左上角。我需要 Spri
有人告诉我,您可以通过以下方式向与当前 Git 分支名称相匹配的远程分支推送和 pull : git push origin HEAD 或 git pull origin HEAD 它以前一直对我有用
我正在使用自定义 View 和 Canvas 在屏幕上绘制对象。 View 位于距屏幕原点的 Y 偏移处。我想平移 Canvas ,然后绘制一个对象。但是,当我使用 setmatrix 平移 Canv
尝试拖动组。为什么 origin 在这里不起作用?注意到当你第一次点击它时它是如何跳跃的吗? JSFIDDLE基于此:http://bl.ocks.org/mbostock/1557377 var d
我正在尝试使用以下立方体的透视视角: http://jsfiddle.net/TrySpace/JvFSQ/5/ 但是我没有按照我的预期去做,我想要改变实际的视角。所以当transformOrigin
我的 OpenShift Origin 安装似乎有问题。 当我获得路由器的端点时,我得到以下信息: oc get endpoints --namespace=default --selector=ro
这是怎么做到的?我正在寻找 iOS7/8 解决方案。 KeyboardWillShow 并不令人满意,因为我需要在键盘实际显示之前根据键盘高度调整 View 大小。 最佳答案 keyboardWill
我正在 iframe 上监听其内容何时发生变化。当它发生时,我想知道内容的当前来源是什么。 我无法访问该内容,因为它违反了相同的域策略,但我只要根据网址或主机知道它显示的内容就可以了。 我可以通过 j
我一直致力于使用 CSS3 创建动画条形图。它在钢筋的两侧运行良好,但钢筋的顶部和底部一直存在问题。 我一直在通过 jQuery 改变它们的 css“高度”属性来缩放边,但我意识到这不是最好的方法。我
Edit3:我的问题与我预期的功能完全不同。我让代码保留下来,也许这对某人有帮助 :)(并且不要忘记调试!)。 我试图找到直线与三角形相交的 vector 。 当前状态:随机交叉,即使鼠标不在地板上和
我需要在原始 View 的坐标中计算 UIView subview 的可见 CGRect。如果比例为 1,我可以正常工作,但如果其中一个 super View 或 View 本身被缩放(收缩),可见的
这个问题类似于以前回答的问题 Fast interpolation over 3D array ,但无法解决我的问题。 我有一个维度为(时间、高度、纬度、经度)的 4D 数组,标记为 y.shape=
我正在制作自定义贴纸包。这是一个 iMessage 扩展应用程序。我继承了 UICollectionView 而不是使用基本的 MSMessagesViewController。因此,只有当我在展开
我使用 CGWindowListCopyWindowInfo 获取所有窗口的列表。它根据屏幕的 左上角 原点为我提供每个窗口的坐标。 如果我使用 NSWindow 的 setFrame 方法,坐标基于
我是一名优秀的程序员,十分优秀!