我有一个自定义的UIView,它有一个专用的,手动设置的纵向和横向框架,因为autoresizingMasks在我的情况下不起作用.
我将此框架设置为:
- (void)viewWillAppear:(BOOL)animated
Run Code Online (Sandbox Code Playgroud)
它按预期工作.
我现在的问题是,我的UIView还有子视图,也有专门的肖像/风景位置.
我将这些子视图放在:
- (void)layoutSubviews
Run Code Online (Sandbox Code Playgroud)
如果我现在离开我在的viewController 如纵向,旋转到另一个的viewController横向的,然后回来这个的viewController我看到我的观点得到了正确的调整,但我的观点的子视图,其中获得定位在layoutSubviews不重新定位还没有,但在视图已经出现后以动画方式调整大小.
我在viewDidAppear中什么也没做,我已经尝试过调用了
- (void)layoutIfNeeded
Run Code Online (Sandbox Code Playgroud)
以及:
- (void)setNeedsLayout
Run Code Online (Sandbox Code Playgroud)
在viewWillAppear中,但它似乎没有任何改变.
我有什么想法我做错了吗?
谢谢.
在iPhone上内置Maps.app上显示方向时,您可以"选择"通过点击它显示的通常3个路线选项之一.我不想复制这个功能并检查一个tap是否在给定的MKPolyline中.
目前我检测到MapView上的点击如下:
// Add Gesture Recognizer to MapView to detect taps
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleMapTap:)];
// we require all gesture recognizer except other single-tap gesture recognizers to fail
for (UIGestureRecognizer *gesture in self.gestureRecognizers) {
if ([gesture isKindOfClass:[UITapGestureRecognizer class]]) {
UITapGestureRecognizer *systemTap = (UITapGestureRecognizer *)gesture;
if (systemTap.numberOfTapsRequired > 1) {
[tap requireGestureRecognizerToFail:systemTap];
}
} else {
[tap requireGestureRecognizerToFail:gesture];
}
}
[self addGestureRecognizer:tap];
Run Code Online (Sandbox Code Playgroud)
我按如下方式处理水龙头:
- (void)handleMapTap:(UITapGestureRecognizer *)tap {
if ((tap.state & UIGestureRecognizerStateRecognized) == UIGestureRecognizerStateRecognized) {
// Check if the …Run Code Online (Sandbox Code Playgroud) iOS 5改变了内置Google Maps App绘制路线的方式:

我现在想在我自己的应用程序中复制路径叠加的设计,但我目前只能绘制一条纯蓝线.我想添加渐变,边框和发光的3D效果.有关如何实现这一目标的任何想法?
目前我正在使用以下代码:
CGContextSetFillColorWithColor(context, fillColor.CGColor);
CGContextSetLineJoin(context, kCGLineJoinRound);
CGContextSetLineCap(context, kCGLineCapRound);
CGContextSetLineWidth(context, lineWidth);
CGContextAddPath(context, path);
CGContextReplacePathWithStrokedPath(context);
CGContextFillPath(context);
Run Code Online (Sandbox Code Playgroud)
导致一条相当难看的线:

谢谢!
更新:该解决方案应适用于iOS 4.0及更高版本.
我可以使用任何C或Objective-C库来检测Mac上的声音模式(例如拍手)吗?
默认情况下,UITabBar绘制一个微妙的渐变:

我想用任何给定的tintColor在我的代码中复制这种外观和感觉.为了说清楚:我不想在UITabBar上设置tintColor(从iOS 5开始就可以),我想在我自己的UIView中绘制渐变.
我知道如何绘制渐变,我的问题是如何从tintColor派生渐变的颜色.我正在考虑获得颜色的亮度并使用不同的亮度设置生成其他颜色,但这似乎不能很好地工作,看起来不像我想要的那样好.

我需要我的开源TabBarController的代码:https://github.com/NOUSguide/NGTabBarController
这是我当前创建渐变的代码:
UIColor *baseColor = self.tintColor;
CGFloat hue, saturation, brightness, alpha;
// TODO: Only works on iOS 5
[baseColor getHue:&hue saturation:&saturation brightness:&brightness alpha:&alpha];
// That's the question, how to compute the colors ...
NSArray *colors = [NSArray arrayWithObjects:
[UIColor colorWithHue:hue saturation:saturation brightness:brightness+0.2 alpha:alpha],
[UIColor colorWithHue:hue saturation:saturation brightness:brightness+0.15 alpha:alpha],
[UIColor colorWithHue:hue saturation:saturation brightness:brightness+0.1 alpha:alpha],
baseColor, nil];
NSUInteger colorsCount = colors.count;
CGColorSpaceRef colorSpace = CGColorGetColorSpace([[colors objectAtIndex:0] CGColor]);
NSArray *locations = [NSArray arrayWithObjects:[NSNumber numberWithFloat:0.0],
[NSNumber numberWithFloat:0.25], …Run Code Online (Sandbox Code Playgroud)