snipt

Ctrl+h for KB shortcuts

Swift

Traer tamaño de la pantalla swift

1
2
3
4
    // se trae el tamaño de la pantalla el cual devuelve un objecto con width y heigth
    let ios_screen_size = UIScreen.mainScreen().bounds.size;
    // se genera un elemento ui view en la vista con (,,ancho del tamaño de la pantalla actual,alto de 40)
    let header = UIView.init(frame: CGRectMake(0, 0, ios_screen_size.width, 40))
https://snipt.net/embed/cc1c9fce837f33ebeff260fee4b9e28d/
https://snipt.net/raw/cc1c9fce837f33ebeff260fee4b9e28d/
cc1c9fce837f33ebeff260fee4b9e28d
swift
Swift
4
2016-10-01T07:35:26
True
False
False
Apr 19, 2016 at 04:34 PM
/api/public/snipt/145517/
traer-tamano-de-la-pantalla-swift
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a> <span class="c1">// se trae el tamaño de la pantalla el cual devuelve un objecto con width y heigth</span> </span><span id="L-2"><a name="L-2"></a> <span class="kd">let</span> <span class="nv">ios_screen_size</span> <span class="p">=</span> <span class="bp">UIScreen</span><span class="p">.</span><span class="n">mainScreen</span><span class="p">().</span><span class="n">bounds</span><span class="p">.</span><span class="n">size</span><span class="p">;</span> </span><span id="L-3"><a name="L-3"></a> <span class="c1">// se genera un elemento ui view en la vista con (,,ancho del tamaño de la pantalla actual,alto de 40)</span> </span><span id="L-4"><a name="L-4"></a> <span class="kd">let</span> <span class="nv">header</span> <span class="p">=</span> <span class="bp">UIView</span><span class="p">.</span><span class="kd">init</span><span class="p">(</span><span class="n">frame</span><span class="p">:</span> <span class="n">CGRectMake</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="n">ios_screen_size</span><span class="p">.</span><span class="n">width</span><span class="p">,</span> <span class="mi">40</span><span class="p">))</span> </span></pre></div> </td></tr></table>
swift

Swift

abrir una pagina externa desde el navegador con swift

1
2
3
// abrir una pagina externa desde el navegador con swift
let url = NSURL(string: "http://localhost:3000/users/password/new")!
UIApplication.sharedApplication().openURL(url)
https://snipt.net/embed/334ca397e6ba22e984ee5222f4064936/
https://snipt.net/raw/334ca397e6ba22e984ee5222f4064936/
334ca397e6ba22e984ee5222f4064936
swift
Swift
3
2016-10-01T07:33:19
True
False
False
/api/public/snipt/145513/
abrir-una-pagina-externa-desde-el-navegador-con-swift
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a><span class="c1">// abrir una pagina externa desde el navegador con swift</span> </span><span id="L-2"><a name="L-2"></a><span class="kd">let</span> <span class="nv">url</span> <span class="p">=</span> <span class="bp">NSURL</span><span class="p">(</span><span class="n">string</span><span class="p">:</span> <span class="s">&quot;http://localhost:3000/users/password/new&quot;</span><span class="p">)</span><span class="o">!</span> </span><span id="L-3"><a name="L-3"></a><span class="bp">UIApplication</span><span class="p">.</span><span class="n">sharedApplication</span><span class="p">().</span><span class="n">openURL</span><span class="p">(</span><span class="n">url</span><span class="p">)</span> </span></pre></div> </td></tr></table>
swift
Copyrighted, illegal, or inappropriate content? Email support@snipt.net.