标签: uiview

UIView绝对屏幕点

有没有一种简单的方法来获得UIView的绝对点?绝对我的意思是UIView在iPad上相对于1024x768的位置?

我需要一个简单的方法,因为我在UITableView内部的UITutView内部有一个UIButView视图,该视图由一个viewcontroller呈现,该视图控制器是另一个视图控制器的子节点,重复到第五或第六视图控制器.由于这种复杂的设计,我需要UIButton的绝对矩形,所以我可以在"main"viewcontroller上显示一个UIActionSheet.

objective-c uiview ios cgrect

0
推荐指数
1
解决办法
1万
查看次数

如何使用一个UIBezierPath创建两个不同颜色的笔划

我试图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)

objective-c uiview ios uibezierpath

0
推荐指数
1
解决办法
4104
查看次数

ng-repeat使用标签的问题

我在使用选项卡内部的链接时遇到了问题,这些链接会更改视图并替换选项卡.仅在选项卡中使用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

0
推荐指数
1
解决办法
4237
查看次数

UILabel没有像预期的那样出现延迟序列

我想让我的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)

core-animation uiview ios swift

0
推荐指数
1
解决办法
71
查看次数

在viewDidLayoutSubviews中以编程方式创建UIView

我想以编程方式创建依赖于边界大小的UIViews self.view.我已经把代码放在了创建UIViews中viewDidLayoutSubviews.

问题是viewDidLayoutSubviews当我的viewController出现在屏幕上时多次调用,从而创建了UIView的多个实例.我想这可以通过使用某种旗帜来解决.

有一个更好的方法吗?代码应该放在视图控制器生命周期的其他地方吗?

uiview ios

0
推荐指数
1
解决办法
755
查看次数

添加按钮到以编程方式创建的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完全相同的位置,宽度和高度

但结果就是这样

在此输入图像描述

我的代码出了什么问题?

提前致谢

button uiview ios swift

0
推荐指数
2
解决办法
3761
查看次数

如何在目标c中启用自动布局时增加uiview的高度

我尝试使用下面的代码以编程方式在运行时关闭接口构建器中的特定子视图的自动布局.

[view removeConstraints:view.constraints];
Run Code Online (Sandbox Code Playgroud)

有人建议这样做:

如果您需要更改自动布局处于活动状态的视图的高度,则需要为高度约束创建一个IBOutlet并在运行时修改它,即:

@IBOutlet weak var heightConstraint: NSLayoutConstraint!
self.heightConstraint.constant = 200
Run Code Online (Sandbox Code Playgroud)

但我不明白这意味着什么.

objective-c uiview ios autolayout

0
推荐指数
1
解决办法
1708
查看次数

iOS - UIView setCenter在UIView animateWithDuration中不起作用

我有一个让我疯狂的问题,我想我没有足够的知识来找到这个问题的答案.

这里有一个完美的代码:

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,一切都很好.

iphone animation objective-c uiview ios

0
推荐指数
1
解决办法
690
查看次数

点击xcode/swift 3中的视图以"选择"它

我正在努力研究用于"选择"UIViews的方法.在我的用户界面中,我有几个UIViews,我希望它是"可选择的".选中后,我将拥有控件来执行基本调整,例如alpha(让用户知道选择了哪个视图),以及略微更高级的功能,例如显示一组独特的菜单项.一次只能选择1个视图.这里没有多点触控.

问题是,我只看到过UICollectionViewCells.我的界面没有使用集合视图,所以这是不可能的.

进入此过程的思维过程是1点击手势以"选择"uiview,然后通过点击视图边界外部来"取消选择"它.

另一个思考过程是使用UIButtons而不是UIViews来利用Selected状态.

哪个是更可行的解决方案?使用UIViews甚至可以实现这一点吗?或者我应该回溯并转而使用UIButtons?

谢谢.

uibutton uiview ios swift swift3

0
推荐指数
1
解决办法
5716
查看次数

如何从视图中获取所有按钮?

我尝试从中获取所有按钮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)

请帮忙。

objective-c uibutton uiview ios

0
推荐指数
1
解决办法
1134
查看次数