我有一个滚动的DIV,其中包含许多项目的列表:
___________
| |^|
| Item1 | |
|_________| |
| | |
| Item2 | |
|_________| |
| | |
| Item3 | |
|_________|v|
Run Code Online (Sandbox Code Playgroud)
当用户滚动列表项时,会出现一个描述该项的弹出窗口:
___________
| |^|
| Item1 | |
|_________| |
| _|_|____________________
| Item2 | Description for item 2 |
|________------------------------
| | |
| Item3 | |
|_________|v|
Run Code Online (Sandbox Code Playgroud)
困境是滚动div必须有溢出:auto,但弹出窗口想要在div之外可见.所以目前,我的弹出窗口被切断了:
___________
| |^|
| Item1 | |
|_________| |
| _|_|
| Item2 | De|
|________---|
| | |
| Item3 | | …Run Code Online (Sandbox Code Playgroud) 当我在手机上玩时,我注意到我的UISegmentedControl响应不是很快.需要2次或更多次尝试才能使我的水龙头注册.所以我决定在Simulator中运行我的应用程序,以更准确地探测出错了什么.通过用鼠标点击几十次,我确定UISegmentedControl的前25%没有响应(下面的屏幕截图中的部分用Photoshop突出显示为红色).我不知道有什么看不见的UIView可以阻止它.你知道怎么让整个控件可以安装吗?

self.segmentedControl = [[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObjects:@"Uno", @"Dos", nil]];
self.segmentedControl.selectedSegmentIndex = 0;
[self.segmentedControl addTarget:self action:@selector(segmentedControlChanged:) forControlEvents:UIControlEventValueChanged];
self.segmentedControl.height = 32.0;
self.segmentedControl.width = 310.0;
self.segmentedControl.segmentedControlStyle = UISegmentedControlStyleBar;
self.segmentedControl.tintColor = [UIColor colorWithWhite:0.9 alpha:1.0];
self.segmentedControl.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin;
UIView* toolbar = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.width, HEADER_HEIGHT)];
toolbar.autoresizingMask = UIViewAutoresizingFlexibleWidth;
CAGradientLayer *gradient = [CAGradientLayer layer];
gradient.frame = CGRectMake(
toolbar.bounds.origin.x,
toolbar.bounds.origin.y,
// * 2 for enough slack when iPad rotates
toolbar.bounds.size.width * 2,
toolbar.bounds.size.height
);
gradient.colors = [NSArray arrayWithObjects:
(id)[[UIColor whiteColor] CGColor],
(id)[[UIColor
colorWithWhite:0.8 …Run Code Online (Sandbox Code Playgroud)

我试图达到与Apple的Contacts应用程序相同的效果(左侧截图).即使键盘被解除,UISearchBar中的取消按钮也会启用.我的应用程序行为不同(右侧截图).键盘解除后,取消按钮自动禁用.用户被迫点击取消按钮一次以启用它,然后再次点击实际触发解雇.这不是很好的用户体验.如何启用取消按钮,如Apple的联系人应用程序?
技术细节:
UISearchDisplayController由于某些设计要求,我没有使用.这只是UISearchBar我自己的自定义搜索控制器.取消按钮显示使用[self.searchBar showsCancelButton:YES animated:YES].键盘被解雇使用[self.searchBar resignFirstResponder].
我有一个半透明填充和阴影的UIView.由于填充是半透明的,我可以看到填充后面的阴影.
- (id)init
{
self = [super init];
if (self) {
self.backgroundColor = [UIColor colorWithWhite:1.0 alpha:0.8];
self.layer.shadowColor = [UIColor blackColor].CGColor;
self.layer.shadowOffset = CGSizeMake(0.0, 0.0);
self.layer.shadowOpacity = 0.5;
self.layer.shadowRadius = 2.0;
self.layer.cornerRadius = 3.0;
}
return self;
}
Run Code Online (Sandbox Code Playgroud)
我不喜欢这种行为.我无法在视图后面看到任何内容,因为填充的不透明度+阴影的不透明度> 100%.我如何使它像CSS只在框的边框外绘制阴影?
.someStyle {
background: white;
opacity: 0.8;
box-shadow: 0 0 1em rgba(0,0,0,0.5);
}
Run Code Online (Sandbox Code Playgroud) 我想测试Facebook用户的访问令牌已过期的代码路径,我需要更新令牌.我注意到访问令牌在创建后2个月到期.我不想等待2个月来测试该代码路径,所以我想要一种方法来模拟这个过期.如果我从未测试过以下谜团的情况,我害怕我的代码会崩溃:
[FBSession openActiveSessionWithReadPermissions:permArray allowLoginUI:NO completionHandler:someFunction]以静默方式重新连接过去已连接的Facebook用户.请注意allowLoginUI是如何NO.允许用户重新登录和续订令牌是否必须为YES,或者令牌是否可以静默更新?FBSessionStateOpen和FBSessionStateOpenTokenExtended.当令牌扩展时,状态机是否保持在令牌扩展状态,还是会进入扩展状态然后立即进入打开状态?我需要知道状态转换,所以我不会运行两次处理程序.[FBSession activeSession].accessToken成为零或者它依然如旧过期的令牌?[FBSession activeSession].expirationDate:是零,旧的到期日期,还是自动成为新的到期日期?我的应用程序似乎布局正确,但我无法实现iOS 7着名的模糊半透明效果.我看起来不透明.

我正试图获得更明显的模糊效果,例如Apple的预告片应用:

在我的UINavigationController的子类中,我使导航栏半透明:
- (id)initWithRootViewController:(UIViewController *)rootViewController
{
if (self = [super initWithRootViewController:rootViewController]) {
self.navigationBar.translucent = YES;
}
return self;
}
Run Code Online (Sandbox Code Playgroud)
在我的UIApplicationDelegate的子类中,我设置了导航栏的色调颜色.我发现色调的颜色没有区别.也就是说,使用0.1的α不会导致条形变得更透明.
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[[UINavigationBar appearance] setTintColor:[UIColor greenColor]];
}
Run Code Online (Sandbox Code Playgroud)
在我的内容视图控制器中,我将边缘设置为,UIRectEdgeNone以便顶部不会被导航栏切断.如果我使用默认设置UIRectEdgeAll,导航栏将永久覆盖我的内容的顶部.即使我生活在这种异常中,UIRectEdgeAll仍然没有启用半透明效果.
- (void) viewDidLoad
{
[super viewDidLoad];
self.edgesForExtendedLayout = UIRectEdgeNone;
}
Run Code Online (Sandbox Code Playgroud)
广告在@rmaddy的评论中指出,问题可能与edgeForExtendedLayout有关.我找到了一个全面的教程edgesForExtendedLayout并试图实现它:
- (void) viewDidLoad
{
[super viewDidLoad];
self.edgesForExtendedLayout = UIRectEdgeAll;
self.automaticallyAdjustsScrollViewInsets = YES;
self.extendedLayoutIncludesOpaqueBars = NO;
}
Run Code Online (Sandbox Code Playgroud)
那没起效.首先,没有半透明效应.其次,我的内容被删除了.在下面带有上述代码的示例页面上,头像最初被导航栏覆盖,很难滚动到.您可以下拉以查看头像的顶部,但是当您放开时,页面会自动反弹并且头像会再次被遮挡.

在我的应用程序委托的didFinishLaunchingWithOptions函数中,我尝试自定义导航栏的外观.
[UINavigationBar appearance].translucent = NO;
[[UINavigationBar appearance]
setBackgroundImage:[UIImage
imageWithColor:[UIColor whiteColor]
size:CGSizeMake(1.0f, 1.0f)
]
forBarMetrics:UIBarMetricsDefault
];
[UINavigationBar appearance].shadowImage = [UIImage
imageWithColor:[UIColor redColor]
size:CGSizeMake(0.5f, 0.5f)
];
Run Code Online (Sandbox Code Playgroud)
我期待一个1px高的不透明红色阴影.相反,我给了一个2px高的半透明红色阴影.怎么能让它看起来像我想要的那样?我已经对UITabBar进行了类似的外观设置.另一方面,它表现得很好.

创建动态图像的类别函数定义如下:
+ (UIImage*)imageWithColor:(UIColor *)color size:(CGSize)size
{
CGRect rect = CGRectMake(0.0f, 0.0f, size.width, size.height);
UIGraphicsBeginImageContext(rect.size);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetFillColorWithColor(context, [color CGColor]);
CGContextFillRect(context, rect);
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return image;
}
Run Code Online (Sandbox Code Playgroud) 当我调用sizeToFit其中一个视图时,我注意到iOS框架首先调用sizeThatFits然后调用layoutSubviews该视图.这对我来说是有问题的,因为我的计算sizeThatFits取决于我的结果layoutSubviews.在以下示例中,调整layoutSubviews子视图并使用此子视图的高度sizeThatFits.目前我的代码不工作,订单是颠倒的.
在我的视图中控制器的viewDidLoad:
UIView* header = [[MyHeader alloc] init];
[header sizeToFit];
self.tableView.tableHeaderView = header;
[header release];
Run Code Online (Sandbox Code Playgroud)
在我看来:
- (void) layoutSubviews {
[super layoutSubviews];
[self.subView sizeToFit];
}
- (CGSize) sizeThatFits:(CGSize)size {
return CGSizeMake(
self.frame.size.width,
self.subView.frame.size.height
);
}
Run Code Online (Sandbox Code Playgroud) 我想为一个元素设置动画,就好像你在俯视地球一样.元素向你跳跃,击中它的顶点,然后向下跌落一点.轨迹的侧视图如下:
_
/ \
/ |
|
|
Run Code Online (Sandbox Code Playgroud)
我无法通过关键帧动画获得逼真的效果.我看起来像这样人造:
/\
/ \
/
/
/
Run Code Online (Sandbox Code Playgroud)
CSS
@keyframes springIn {
0% {
transform: scale(0.0);
}
80% {
transform: scale(1.2);
}
100% {
transform: scale(1.0);
}
}
.someElement {
animation: springIn 1s linear 1s 1 forwards;
}
Run Code Online (Sandbox Code Playgroud)
如何在动画上放置抛物线函数以获得重力效果?我以为我可以使用Bezier曲线,但CSS标准不允许[0,0]之外的点.
我有一个大型网站,所以我的CSS文件夹结构可能相当深.任何CSS文件都可以通过相对URL设置元素的背景图像.在发布到我的生产服务器之前,我需要缩小所有CSS文件.这种缩小过程可能会破坏一些相对URL,因为它有效地使文件夹结构变平.作为开发人员,您如何处理开发代码和生产代码之间的这种差异?
这是我的文件夹结构:
image/
article/
brushStroke.jpg
style/
module/
button.css
page/
article/
introToPainting.css
minified/
style20130522.css
Run Code Online (Sandbox Code Playgroud)
在开发过程中,我可能在introToPainting.css中有这个CSS规则:
#step1 {
background-image: url(../../../image/article/brushStroke.jpg);
}
Run Code Online (Sandbox Code Playgroud)
让我们说一个特定的简单页面,我只需要button.css和introToPainting.css.对于生产版本,这两个CSS文件将缩小为style20130522.css.现在,精缩文件驻留在不同的文件夹深度比introToPainting.css,路径brushStroke.jpg现在是错误的.
ios ×7
cocoa-touch ×6
css ×3
ios7 ×2
iphone ×2
facebook ×1
minify ×1
physics ×1
uiappearance ×1
uisearchbar ×1
uiview ×1
web ×1