有没有一种简单的方法来获得UIView的绝对点?绝对我的意思是UIView在iPad上相对于1024x768的位置?
我需要一个简单的方法,因为我在UITableView内部的UITutView内部有一个UIButView视图,该视图由一个viewcontroller呈现,该视图控制器是另一个视图控制器的子节点,重复到第五或第六视图控制器.由于这种复杂的设计,我需要UIButton的绝对矩形,所以我可以在"main"viewcontroller上显示一个UIActionSheet.
我试图UIView用手指画线,它用一种颜色很好.如果我尝试更改颜色并再次绘制,则之前的UIBezierPath颜色也会更改为新颜色.因此,我无法绘制不同的颜色线,保持前一个颜色线UIView
我将所有属性(path,linecolor)设置为非原子和强大的属性 UIView
以供参考:
选择颜色后,我在颜色选择器委托方法中更改了我的UIView的描边颜色:
#pragma mark - FCColorPickerViewControllerDelegate Methods
-(void)colorPickerViewController:(FCColorPickerViewController *)colorPicker didSelectColor:(UIColor *)color {
self.drawView.lineColor = color; //this works fine
// self.drawView.path=[UIBezierPath bezierPath]; tried this to create new bezier path with new color, but this erases the olde bezier path and return new
// [self.drawView.lineColor setStroke]; tried this
// [self.drawView.lineColor setFill]; tried this
[self dismissViewControllerAnimated:YES completion:nil]; //dismiss the color picker
}
Run Code Online (Sandbox Code Playgroud)
这是我的绘图方法:
- (id)initWithCoder:(NSCoder *)aDecoder
{
if (self = [super initWithCoder:aDecoder]) …Run Code Online (Sandbox Code Playgroud) 我在使用选项卡内部的链接时遇到了问题,这些链接会更改视图并替换选项卡.仅在选项卡中使用ng-repeat但在静态选项卡中不使用时才会出现此问题.
那是主页:
<div ui-view name="pageContent">
<uib-tabset>
<uib-tab ng-repeat="tab in tabs" heading="{{tab.name}}" active="tab.active" ng-click="!tab.disable && load(tab.link,tab.id)">
</uib-tab>
<!-- <uib-tab heading="Static title">Static content</uib-tab>
<uib-tab heading="Static title">Static content 2</uib-tab> <!-- when I use the comment code it works. -->
</uib-tabset>
<div>
<a class="btn btn-link" ui-sref="xxxx.yyyyy" role="button">
{{$storage.aaaa.bbbbb}}
</a><!-- this view replace the pageContent -->
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
错误是:
错误:[$ compile:ctreq]无法找到指令'uibTab'所需的控制器'uibTabset'!
提前致谢
uiview angularjs angularjs-ng-repeat angular-ui-router angular-ui-tabset
我想让我的UILabel以延迟的顺序出现.因此一个接一个.当我使用alpha值使它们淡入时,下面的代码可以正常工作,但是当我使用UILabels的.hidden属性时它不会做我想要它做的事情.
代码使我的UILabel同时出现而不是sum1TimeLabel在5秒后出现,sum2TimeLabel在30秒后出现秒,最后sum3TimeLabel出现在60秒后出现.我究竟做错了什么?
override func viewDidAppear(animated: Bool) {
super.viewDidAppear(animated)
UIView.animateWithDuration(5.0, animations: {
self.sum1TimeLabel!.hidden = false;
})
UIView.animateWithDuration(30.0, animations: {
self.sum2TimeLabel!.hidden = false;
})
UIView.animateWithDuration(60.0, animations: {
self.sum3TimeLabel!.hidden = false;
})
}
Run Code Online (Sandbox Code Playgroud) 我想以编程方式创建依赖于边界大小的UIViews self.view.我已经把代码放在了创建UIViews中viewDidLayoutSubviews.
问题是viewDidLayoutSubviews当我的viewController出现在屏幕上时多次调用,从而创建了UIView的多个实例.我想这可以通过使用某种旗帜来解决.
有一个更好的方法吗?代码应该放在视图控制器生命周期的其他地方吗?
我以编程方式创建了UIView和Button
var width = self.view.frame.width - 8
var height = width/8
newView.frame = CGRectMake(4, 39, width, height)
newView.backgroundColor = UIColor.greenColor()
self.view.addSubview(newView)
var button = UIButton.buttonWithType(UIButtonType.System) as! UIButton
button.frame = newView.frame
button.backgroundColor = UIColor.whiteColor()
button.addTarget(self, action: "buttonAction:", forControlEvents: UIControlEvents.TouchUpInside)
button.setTitle(" All Hospitals/Clinics", forState: UIControlState.Normal)
button.setTitleColor(UIColor.blackColor(), forState: .Normal)
button.contentHorizontalAlignment = UIControlContentHorizontalAlignment.Left
newView.addSubview(button)
Run Code Online (Sandbox Code Playgroud)
我希望按钮位于UIView内部,并且具有与UIView完全相同的位置,宽度和高度
但结果就是这样
我的代码出了什么问题?
提前致谢
我尝试使用下面的代码以编程方式在运行时关闭接口构建器中的特定子视图的自动布局.
[view removeConstraints:view.constraints];
Run Code Online (Sandbox Code Playgroud)
有人建议这样做:
如果您需要更改自动布局处于活动状态的视图的高度,则需要为高度约束创建一个IBOutlet并在运行时修改它,即:
Run Code Online (Sandbox Code Playgroud)@IBOutlet weak var heightConstraint: NSLayoutConstraint! self.heightConstraint.constant = 200
但我不明白这意味着什么.
我有一个让我疯狂的问题,我想我没有足够的知识来找到这个问题的答案.
这里有一个完美的代码:
NSLog(@"%f, %f", imageList.center.x, imageList.center.y);
[imageList setCenter:CGPointMake(imageList.center.x, -imageList.center.y)];
NSLog(@"=> %f, %f", imageList.center.x, imageList.center.y);
Run Code Online (Sandbox Code Playgroud)
给我以下输出:
2016-01-08 11:48:42.585 User[4047:600095] 160.000000, 284.000000
2016-01-08 11:48:42.585 User[4047:600095] => 160.000000, -284.000000
Run Code Online (Sandbox Code Playgroud)
现在,如果我把这个setCenter放到UIView animationWithDuration中,就像这样
NSLog(@"%f, %f", imageList.center.x, imageList.center.y);
[UIView animateWithDuration:0.3 animations:^{
[imageList setCenter:CGPointMake(imageList.center.x, -imageList.center.y)];
} completion:^(BOOL finished) {*/
NSLog(@"=> %f, %f", imageList.center.x, imageList.center.y);
}];
Run Code Online (Sandbox Code Playgroud)
我得到这个输出:
2016-01-08 11:48:42.585 User[4047:600095] 160.000000, 284.000000
2016-01-08 11:48:42.585 User[4047:600095] => 160.000000, 284.000000
Run Code Online (Sandbox Code Playgroud)
你们有什么想法吗?我检查了约束和autoLayout,一切都很好.
我正在努力研究用于"选择"UIViews的方法.在我的用户界面中,我有几个UIViews,我希望它是"可选择的".选中后,我将拥有控件来执行基本调整,例如alpha(让用户知道选择了哪个视图),以及略微更高级的功能,例如显示一组独特的菜单项.一次只能选择1个视图.这里没有多点触控.
问题是,我只看到过UICollectionViewCells.我的界面没有使用集合视图,所以这是不可能的.
进入此过程的思维过程是1点击手势以"选择"uiview,然后通过点击视图边界外部来"取消选择"它.
另一个思考过程是使用UIButtons而不是UIViews来利用Selected状态.
哪个是更可行的解决方案?使用UIViews甚至可以实现这一点吗?或者我应该回溯并转而使用UIButtons?
谢谢.
我尝试从中获取所有按钮UIView。我尝试了此代码,但无法正常工作。
for (UIView *subview in self.view.subviews)
{
if ([subview isKindOfClass:[UIButton class]]
{
NSLog(@"found a button!");
subview.layer.borderWidth = 1.0f;
subview.layer.borderColor = [[UIColor whiteColor] CGColor];
[subview.layer setCornerRadius: subview.frame.size.width/2.0f];
NSLog(@"button.tag = %ld", (long)subview.tag);
}
}
Run Code Online (Sandbox Code Playgroud)
请帮忙。
uiview ×10
ios ×9
objective-c ×5
swift ×3
uibutton ×2
angularjs ×1
animation ×1
autolayout ×1
button ×1
cgrect ×1
iphone ×1
swift3 ×1
uibezierpath ×1