标签: label

如何动态计算UILabel高度?

我想从给定的文本中动态计算UILabel的行数和高度.

iphone label uilabel ios

72
推荐指数
7
解决办法
11万
查看次数

在代码中设置WPF标签的Style属性?

在App.xaml中,我有以下代码:

<Application.Resources>
    <Style x:Key="LabelTemplate" TargetType="{x:Type Label}">
        <Setter Property="Height" Value="53" />
        <Setter Property="Width" Value="130" />
        <Setter Property="HorizontalAlignment" Value="Left" />
        <Setter Property="Margin" Value="99,71,0,0" />
        <Setter Property="VerticalAlignment" Value= "Top" />
        <Setter Property="Foreground" Value="#FFE75959" />
        <Setter Property="FontFamily" Value="Calibri" />
        <Setter Property="FontSize" Value="40" />
    </Style>
</Application.Resources>
Run Code Online (Sandbox Code Playgroud)

这是为了为我的标签提供通用模板.

在主要的XAML代码中,我有以下代码行:

<Label Content="Movies" Style="{StaticResource LabelTemplate}" Name="label1" />
Run Code Online (Sandbox Code Playgroud)

但是,我想通过代码初始化Style属性.我试过了:

label1.Style = new Style("{StaticResource LabelTemplate}");
Run Code Online (Sandbox Code Playgroud)

label1.Style = "{StaticResource LabelTemplate}";
Run Code Online (Sandbox Code Playgroud)

两种解决方案都无效.

任何帮助,将不胜感激 :).

c# wpf user-interface label

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

归因于文本中心对齐

我已经尝试了一切但似乎无法将这个文本集中在一起.有人可以告诉我错误在哪里.

NSMutableParagraphStyle *paragraphStyle = NSMutableParagraphStyle.new;
paragraphStyle.alignment = NSTextAlignmentCenter;
label.attributedText = [[NSAttributedString alloc] initWithString:cell.EventTitle.text attributes:@{NSForegroundColorAttributeName : [UIColor whiteColor],NSParagraphStyleAttributeName:paragraphStyle,NSBaselineOffsetAttributeName : @0,NSFontAttributeName : [UIFont fontWithName:@"BrandonGrotesque-Black" size:34]}];
Run Code Online (Sandbox Code Playgroud)

xcode label nsattributedstring centering ios

71
推荐指数
8
解决办法
6万
查看次数

matplotlib设置yaxis标签大小

如何更改yaxis标签的大小?现在,我使用更改所有标签的大小

pylab.rc('font', family='serif', size=40)
Run Code Online (Sandbox Code Playgroud)

但在我的情况下,我想使y轴标签大于x轴.但是,我想单独留下刻度标签.

我试过,例如:

pylab.gca().get_ylabel().set_fontsize(60)
Run Code Online (Sandbox Code Playgroud)

但我只得到:

AttributeError: 'str' object has no attribute 'set_fontsize'
Run Code Online (Sandbox Code Playgroud)

所以,显然这不起作用.我已经看到很多用于刻度尺寸的东西,但轴标签本身没有.

python graphing label matplotlib

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

如何在INPUT标记上没有ID属性的情况下使用LABEL标记的FOR属性

是否有解决下面代码中说明的问题的方法?首先在浏览器中打开代码直接到达关键点,而不必在知道您要查找的内容之前查看所有代码.

<html>
 <head>
  <title>Input ID creates problems</title>
  <style type="text/css">
   #prologue, #summary { margin: 5em; }
  </style>
 </head>
 <body>
  <h1>Input ID creates a bug</h1>
  <p id="prologue">
   In this example, I make a list of checkboxes representing things which could appear in a book. If you want some in your book, you check them:
  </p>
  <form>
   <ul>
    <li>
     <input type="checkbox" id="prologue" />
     <label for="prologue">prologue</label>
    </li>
    <li>
     <input type="checkbox" id="chapter" />
     <label for="chapter">chapter</label>
    </li>
    <li>
     <input type="checkbox" id="summary" />
     <label for="summary">summary</label>
    </li>
    <li> …
Run Code Online (Sandbox Code Playgroud)

html label for-loop input

65
推荐指数
3
解决办法
6万
查看次数

对PictureBox的透明控制

在我的C#表单中,我有一个标签,在下载事件中显示下载百分比:

  this.lblprg.Text = overallpercent.ToString("#0") + "%";
Run Code Online (Sandbox Code Playgroud)

Label控件的BackColor属性设置为透明,我希望它显示在PictureBox上.但这似乎不能正常工作,我看到一个灰色的背景,它在图片框的顶部看起来不透明.我怎样才能解决这个问题?

c# label background

64
推荐指数
4
解决办法
13万
查看次数

标签从右向左增长

我的表格上有一个标签,位于表格的右侧.此标签加载动态文本.

有时它加载的文本太长,文本越过表单的边框,这是一些文本不在表单中.

我想让标签从右到左而不是从左到右.我该如何实现这一目标?

.net c# label winforms

62
推荐指数
4
解决办法
5万
查看次数

CSS显示:内联块不接受margin-top?

我有一个显示元素:inline-block,但它似乎不接受margin-top.这是因为元素仍被视为内联元素吗?

如果是,有没有人有解决方法?


编辑#1:

我的CSS非常简单:

.label {
  background: #ffffff;
  display: inline-block;
  margin-top: -2px;
  padding: 7px 7px 5px;
}
Run Code Online (Sandbox Code Playgroud)

我最终将内容包装在另一个div中并给出了一个优势.但这会导致大量额外的标记,并使我的代码不那么清晰.

编辑#2:

margin-top&margin-bottomon inline-block元素似乎只与正值一起使用.

css label position margin

62
推荐指数
4
解决办法
6万
查看次数

如何在Java中设置标签(彩色文本)的颜色?

如何设置标签文本的颜色?

myLabel.setText("Text Color: Red");
myLabel.???
Run Code Online (Sandbox Code Playgroud)

我可以在一个标签中使用两种单独的颜色吗?

例如这里:

"Text Color:"是黑色,"Red"是红色的.

java fonts text label colors

61
推荐指数
4
解决办法
24万
查看次数

更改网格间隔并在Matplotlib中指定刻度标签

我试图在网格图中绘制计数,但我无法弄清楚我是如何去做的.我想要:

  1. 以5为间隔有网格

  2. 每20个主要的刻度标签

  3. 我希望刻度线在情节之外.

  4. 在这些网格中"有计数"

我已经检查了这里这里的潜在重复项,但是我还没弄清楚.

这是我的代码.

import matplotlib.pyplot as plt
from matplotlib.ticker import MultipleLocator, FormatStrFormatter

for key, value in sorted(data.items()):
    x = value[0][2]
    y = value[0][3]
    count = value[0][4]

    fig = plt.figure()
    ax = fig.add_subplot(111)

    ax.annotate(count, xy = (x, y), size = 5)
    # Overwrites and I only get the last data point

    plt.close()
    # Without this, I get "fail to allocate bitmap" error

plt.suptitle('Number of counts', fontsize = 12)
ax.set_xlabel('x')
ax.set_ylabel('y')
plt.axes().set_aspect('equal')

plt.axis([0, 1000, …
Run Code Online (Sandbox Code Playgroud)

python grid plot label matplotlib

60
推荐指数
2
解决办法
17万
查看次数