我必须实现这样的目标(请查看附带的ScreenShot).我想到的最好的解决方案是UICollectionView.我在单元格上创建了圆形边框,并在单元格上放了一个按钮.现在的点直线我用CAShapeLayer用BezierPath,并添加图层到我的collectionview background with background color set to clear color.问题来了,我没有看到任何虚线.这是我尝试过的.现在我有几个问题.回答时请考虑我作为初学者.
1)为什么我的线条没有显示.
2)如何计算两个单元格之间的宽度,现在我正在设置一个随机数.
3)是否有任何其他方法可以更有效地解决此用例.
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
UIBezierPath *borderPath;
CGFloat borderWidth;
KKCollectionCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"testCell" forIndexPath:indexPath];
borderPath = [UIBezierPath bezierPath];
[borderPath moveToPoint:CGPointMake(cell.frame.origin.x + cell.frame.size.width -1 , cell.frame.origin.y + 2)];
[borderPath addLineToPoint:CGPointMake(cell.frame.origin.x + cell.frame.size.width + 50, cell.frame.origin.y +2)];
borderWidth = 1.0;
[self dottedLineWithPath:borderPath withborderWidth:borderWidth];
return cell;
}
/** creating dotted line **/
- (void)dottedLineWithPath:(UIBezierPath *)path withborderWidth:(CGFloat)lineWidth
{
CAShapeLayer *shapelayer = [CAShapeLayer …Run Code Online (Sandbox Code Playgroud) 我有一个超过15的观点UITextFields.我必须为所有人设置bottomBorder(扩展名)UITextFields.我可以为所有人UITextFields和它的工作一个接一个地设置它.我想UITextFields一次为所有人设置底部边框.这是我正在尝试的代码,但似乎for循环没有执行.我甚至尝试过,viewDidLayoutSubViews但是循环也不在那里执行.
override func viewDidLoad()
{
super.viewDidLoad()
/** setting bottom border of textfield**/
for case let textField as UITextField in self.view.subviews {
textField.setBottomBorder()
}
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 Xcode 7.1.1 在 iOS 9.2 设备上测试我的应用程序,并收到错误消息
“找不到开发者磁盘映像”。
谷歌搜索发现,这是由于Version MismatchXcode 部署目标和 iOS 版本之间的原因。在 Xcode 7.1 上,我只能看到deployment target直到 iOS 9.1。
所以,我明白必须将我的 Xcode 更新到 7.2 版本才能部署目标 iOS 9.2。但我不想做更新。
有什么有效的方法可以在 iOS 9.2 设备上使用 Xcode 7.1 测试我的应用程序吗?
我知道这是一个非常简单的问题,我从3小时开始研究它,但却无法使其正常工作.我试图实现UIAlertController使用Apple文档显示错误消息,但我在这一行上得到错误,没有已知的选择器presentViewController的类方法[self presentViewController:alert animated:YES completion:nil];我搜索并获得了许多解决方案,但没有在这里工作.AlertMessageViewController是我的自定义类,它继承自UIViewController.
AlertMessageViewController.h
#import <UIKit/UIKit.h>
@interface AlertMessageViewController : UIViewController
+(instancetype)showAlert: (NSString *) title withMessage: (NSString*) message preferredStyle:(UIAlertControllerStyle)preferredStyle;
@end
AlertMessageViewController.m
#import "AlertMessageViewController.h"
#import <UIKit/UIKit.h>
@interface AlertMessageViewController ()
@end
@implementation AlertMessageViewController
- (void)viewDidLoad {
[super viewDidLoad];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
}
+(instancetype)showAlert: (NSString *) title withMessage: (NSString*) message preferredStyle:(UIAlertControllerStyle)preferredStyle
{
UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"title" message:@"alertMessage" preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *ok =[UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action){NSLog(@"ok action");}];
[alert addAction:ok];
[self presentViewController:alert animated:YES completion:nil];
}
@end
Run Code Online (Sandbox Code Playgroud)