小编jgl*_*ano的帖子

缩放UIView而不缩放子视图

我试图在不缩放其子视图的情况下缩放UIView,或者在我的情况下,我只想在一个轴上缩放子视图.我需要这些层次结构,因为我正在设置一些手势识别器来检测平移和旋转,我希望这些与父视图同时发生.

但是,我不希望缩放同时发生.对于某些子视图,我希望它只在垂直或水平方向发生,或根本不进行缩放.

在UIView上使用CGAffineTransform时,有没有办法在UIView的子视图中控制自动缩放?

iphone scale uiview cgaffinetransform ios

7
推荐指数
1
解决办法
4488
查看次数

从当前状态为UIView创建CATransition

我正在尝试使用一个从一侧制作推动画CATransition.我在处理两个的方法中执行此操作UIViews,一个用于背景,另一个用于前景.动画UIView是前景.但是我不希望新内容替换旧内容,所以为了做到这一点,我将所有旧内容从前台移动到后台,UIView期望它只是动画UIView从一侧的推送过渡,而是它取代了旧的UIView.有什么方法可以做我正在尝试做的事情,比如锁定UIViews从前景和背景UIViews有正确内容的那一刻的状态?

我的代码是这样的:

UIView *newView = argView; // argView is the view passed as a parameter to the method
// move views from foreground to background
for (UIView *v in [fgView subviews]) {
    [v removeFromSuperview];
    [bgView addSubview:v];
}

// Slide animation
CATransition *transition = [CATransition animation];
transition.duration = 0.5;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionPush;
transition.subtype = kCATransitionFromLeft;
[fgView.layer addAnimation:transition forKey:nil];
[fgView addSubview:newView];
Run Code Online (Sandbox Code Playgroud)

[编辑] …

iphone core-animation uiview catransition ios

4
推荐指数
1
解决办法
4198
查看次数

自动生成代码以创建具有未知类的对象

我在Python中编写一个脚本,从自定义文本中读取并从中生成Objective-C代码.案文结构如下:

<XClassName> {
    property_name_1 {
        var_name_1: var_value_1
        var_name_2: var_value_2
        property_name_2 {
            var_name_3: var_value_3
        }
        property_name_2 {
            var_name_3: var_value_4
        }
    }
    property_name_3 {
    }
}
Run Code Online (Sandbox Code Playgroud)

导致Objective-C代码如下:

XClassName* object = [[XClassName alloc] init];
object.propertyName1 = [[[object.propertyName1 class] alloc] init];
object.propertyName1.varName1 = varValue1;
object.propertyName1.varName2 = varValue2;
object.propertyName2Array = [NSMutableArray array];
{
    PropertyName2Class propertyName2 = [[PropertyName2Class alloc] init];
    propertyName2.varName3 = varValue3;
    [object.propertyName2Array addObject:propertyName2];
}
{
    PropertyName2Class propertyName2 = [[PropertyName2Class alloc] init];
    propertyName2.varName3 = varValue4;
    [object.propertyName2Array addObject:propertyName2];
}
object.propertyName3 = [[[object.propertyName3 class] alloc] init];
Run Code Online (Sandbox Code Playgroud)

这很好,除了 …

runtime class objective-c instantiation

4
推荐指数
1
解决办法
591
查看次数