标签: uiedgeinsets

使 UITableView 忽略安全区域

我有一个TableView里面的ViewController. 我TableView拉伸了 View SuperMargings(有约束)并禁用了所有SafeAreaInset 选项,但是当我运行我的项目时,我TableView仍然在SafeArea

我怎样才能让我TableView在 iPhone 上全高带缺口?

tableview uiedgeinsets swift safeareaview

5
推荐指数
1
解决办法
4605
查看次数

在 SKSpriteNode 上使用 resizableImageWithCapInsets

我目前正在尝试在 SKSpriteNode 上使用可拉伸图像。

通常,可拉伸图像由方法返回 UIImage::resizableImageWithCapInsets:

所以我写了这段代码:

SKTexture * texture = [SKTexture textureWithImage:[image resizableImageWithCapInsets:UIEdgeInsetsMake(0, 10, 0, 10)]];
SKSpriteNode * node = [SKSpriteNode spriteNodeWithTexture:texture size:CGSizeMake(150, 8)];
Run Code Online (Sandbox Code Playgroud)

但它不起作用。节点在不考虑边缘插入的情况下拉伸自身。难道只有这样吗?

ios uiedgeinsets sprite-kit

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

UITextView contentInset 不起作用

我在 UITextView 中显示文本。我需要对文本应用一些填充。当我使用最高位置的价值时,它就起作用了。如果我将价值用于其他职位,则它不起作用。

 txtt_bgImage     = [UIImage imageNamed:@"txtt_bg_ipad.png"];
                  txtt_bgImageView = [[UIImageView alloc] initWithImage:txtt_bgImage];

          txtt=[[UITextView alloc]initWithFrame:CGRectMake(170, 300, 400, 250)];

          txtt.text=productDescription;



                  [txtt  setFont: [UIFont fontWithName:@"verdana" size:15]];

                  txtt.textColor=[UIColor whiteColor];

                  [txtt setBackgroundColor:[UIColor clearColor]];


                  txtt.contentInset = UIEdgeInsetsMake(15,0,0,0);

                //  [txtt  setTextContainerInset:UIEdgeInsetsMake(7, 7, 0, 0)];

                  txtt_bgImageView.frame=CGRectMake(170, 300, 400, 250);


                  [self.view addSubview:txtt_bgImageView];

                  txtt.editable=NO;

          NSLog(@"text is %@",txtt.text);

                   object.object_screentext = txtt;

          [self.view addSubview:txtt];
Run Code Online (Sandbox Code Playgroud)

objective-c uitextview ios ios6 uiedgeinsets

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

UITextView sizeThatFits给出了一个在Swift中太短的答案

当您尝试sizeThatFits在UITextView上执行操作时,如果您将所述UITextView的高度设置为结果,那么它太短了!这个答案:

UITextView内容大小太短

似乎也不尽如人意,如果检查contentInset文本视图的属性,contentInset则全部设置为零.

uitextview uiedgeinsets swift

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

iOS:增加 UIBarButtonItem 的间距

我做了一个自定义,UINavigationBar看起来像这样:[1]

现在我想增加左栏按钮和左栏按钮之间的间距。我试图用这种方式做到这一点UIEdgeInsets

self.navigationItem.leftBarButtonItem?.imageInsets = UIEdgeInsetsMake(0, 20, 0, 0)
Run Code Online (Sandbox Code Playgroud)

然后它就会尖叫2]:

insets ios uiedgeinsets swift

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

如何在UINavigationBar中水平放置backIndicatorImage

我使用此代码将插图添加到backIndicator导航栏的图像。但是,这仅适用于图像的垂直定位。我只能将图像移至顶部或底部,而不能移至左侧或右侧。看起来左/右插图无效。我不确定可能是什么问题。

 UIEdgeInsets insets = UIEdgeInsetsMake(0, 20, 0, 0); //(20,0,0,0) works fine
 UIImage *backArrowImage = [[UIImage imageNamed:@"Back"] imageWithAlignmentRectInsets:insets];

 [[UINavigationBar appearance] setBackIndicatorImage:backArrowImage];
 [[UINavigationBar appearance] setBackIndicatorTransitionMaskImage:backArrowImage];
Run Code Online (Sandbox Code Playgroud)

我也试过这个:

  UIImage * backArrowImage =[[UIImage imageNamed:@"Back"]resizableImageWithCapInsets:UIEdgeInsetsMake(0, 20, 0, 0) resizingMode:UIImageResizingModeStretch];
Run Code Online (Sandbox Code Playgroud)

如果无法做到这一点,我是否需要返回添加自定义后退按钮?

objective-c uinavigationbar ios uiedgeinsets

4
推荐指数
2
解决办法
2176
查看次数

在UITableViewCell上设置自定义分隔符插入

在我的UITableView我想要一个' 居中 '分隔效果,其中分隔符从左边缩30pt,从右边缩30.我已经设法从Interface Builder设置TableView本身的' Custom Insets '属性,但我不能通过代码重现这种行为(我必须这样做).

特别是,使用这段代码:

self.tableView.separatorColor = .green
self.tableView.separatorStyle = .singleLine
self.tableView.separatorInset = UIEdgeInsets(top: 0, left: 30, bottom: 0, right: 30)
Run Code Online (Sandbox Code Playgroud)

还有这一个:

@objc(tableView:cellForRowAtIndexPath:) func tableView(_ tableView:  UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    let cell = tableView.dequeueReusableCell(withIdentifier: "recent_cell") as! TPExpandableTableViewCell
    //setting cell insets
    cell.separatorInset = separatorInset
    cell.item = items[indexPath.row]
    return cell
}
Run Code Online (Sandbox Code Playgroud)

我在iPhone 6S模拟器上获得了以下输出:

分隔器

似乎分隔符内容视图收缩,但分隔符背景视图不会收缩.我还试图删除设置单元格的separatorInset的行,结果是插入等于UIEdgeInset.zero

我可以确认绿色开启下的白线是与分隔符相关的视图,因为如果我将separatorStyle更改为.none,它会消失

有帮助吗?

uitableview separator ios uiedgeinsets swift

4
推荐指数
2
解决办法
7736
查看次数

UITabbar图像和标题在ipad中不对齐

我正在使用Tabbarcontroller的应用程序(有两个选项卡)在iphone上一切正常但在ipad上两个选项卡都在屏幕的中心

我想在每个标签的中心显示标题和图像(考虑标签宽度是屏幕的一半)

在搜索这些时,我遇到了UIEdgeInsetsMake

将iOS TabBar项目标题调整到它的中心,但没有帮助.

我不明白在哪里放这个代码.我试着将它放在FirstViewController中然后在app delegate中(逐个),但对我来说没有任何作用

这是我的appDelegete代码:

FirstViewController *firstVC = [[FirstViewController alloc] init];
UINavigationController *navController1 = [[UINavigationController alloc] initWithRootViewController:firstVC];
//navController1.title = @"First Tab";
navController1.tabBarItem.image = [UIImage imageNamed:@"first.png"];

SecondViewController *secondVC = [[SecondViewController alloc] init];
UINavigationController *navController2 = [[UINavigationController alloc] initWithRootViewController:secondVC];
navController2.title = @"Second Tab";
navController2.tabBarItem.image = [UIImage imageNamed:@"second.png"];

NSArray *array = [[NSArray alloc] initWithObjects:navController1,navController2, nil];
UITabBarController *tabBarController = [[UITabBarController alloc] init];
 tabBarController.tabBarItem.imageInsets = UIEdgeInsetsMake(0, -50, 0, 50);

tabBarController.viewControllers = array;

[self.window setRootViewController:tabBarController];

self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
return …
Run Code Online (Sandbox Code Playgroud)

uitabbarcontroller ipad ios uiedgeinsets

2
推荐指数
1
解决办法
4222
查看次数