设置字体大小并将其作为导航栏标题的中心

时间:2015-12-05 21:02:55

标签: ios swift

之前我使用过标签,标题为:

import java.awt.List;
import java.io.*;
import java.net.*;
import java.util.ArrayList;

public class GetItems {

    public static void main(String [] args) throws ClassNotFoundException{
        try {
            URL url = new URL("http://localhost:8000/");
            HttpURLConnection connection = (HttpURLConnection)url.openConnection();
            connection.setRequestProperty("RequestType", "getItems");
            connection.connect();


            BufferedReader in = new BufferedReader(new InputStreamReader(
                    connection.getInputStream()));
            String inputLine;

            inputLine = in.readLine();
            System.out.println(inputLine);
            in.close();

        }catch(MalformedURLException e){
            e.printStackTrace();
        }catch(IOException e){
            e.printStackTrace();
        }

    }

    public static Object deserialize(byte[] string) throws IOException, ClassNotFoundException {
        ByteArrayInputStream b = new ByteArrayInputStream(string);
        ObjectInputStream o = new ObjectInputStream(b);
        return o.readObject();
 }
}

我将视图控制器嵌入到导航控制器中并想要相同的标签。 我正在使用 invitationLabel.lineBreakMode = .ByWordWrapping invitationLabel.numberOfLines = 0 invitationLabel.text = "GET 10 FREE XXXXX FOR EVERY CONTACT WHO JOINS XXXXXX" 。 但问题是字体太大而且不合适。那么我如何以标题为中心更改其字体大小

1 个答案:

答案 0 :(得分:0)

我建议你使用像SnapKit这样的库。然后,您可以设置导航栏的左右约束。并使用invitationLabel.adjustsFontSizeToFitWidth = true