Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/svg/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 自动布局VFL和页边距_Ios_Autolayout_Margins - Fatal编程技术网

Ios 自动布局VFL和页边距

Ios 自动布局VFL和页边距,ios,autolayout,margins,Ios,Autolayout,Margins,Autolayout存在一些问题,并使用VFL定义它 我在代码中有一个UILabel和UIImage,我想将它们都对齐到容器的顶部。一切正常,除了UILabel,它的顶部有我无法摆脱的填充物 我使用了一个非常简单的VFL字符串:V:|-0-[labelView]和V:|-0-[imageView] imageView正常工作,但labelView有我无法摆脱的填充 是否有可以关闭的边距或填充设置 任何帮助都将不胜感激。好的,我做了一些研究,多亏了这个链接中的图形:,我才能够想出一个解决方案 子类

Autolayout存在一些问题,并使用VFL定义它

我在代码中有一个UILabel和UIImage,我想将它们都对齐到容器的顶部。一切正常,除了UILabel,它的顶部有我无法摆脱的填充物

我使用了一个非常简单的VFL字符串:V:|-0-[labelView]和V:|-0-[imageView]

imageView正常工作,但labelView有我无法摆脱的填充

是否有可以关闭的边距或填充设置


任何帮助都将不胜感激。

好的,我做了一些研究,多亏了这个链接中的图形:,我才能够想出一个解决方案

子类UILabel并使用以下内容重写drawTextInRect:

- (void)drawTextInRect:(CGRect)rect
{
   CGFloat topInset = self.font.ascender - self.font.descender - self.font.capHeight;

   UIEdgeInsets insets = {-topInset, 0, 0, 0};

   return [super drawTextInRect:UIEdgeInsetsInsetRect(rect, insets)];
}
希望这能帮助其他寻求解决类似问题的人!:-