Top 2 best Torch/Flash/Light/LED Applications for Android
Following are the best torch apps on google play
Super-Rocket LED Torch Light:
This application realy meet the goals for any one wanted an application which support Only torch light.
I figure it out and rant it on first position
Download Super-Rocket Let Torch
Super-Bright LED Flashlight:
I rank this application on 2nd number because it also have others things to play around mean you can change your screen color etc.
Download this app
BEST ARTICLES
Saturday, August 22, 2015
Tuesday, August 18, 2015
How to integrate Facebook With Parse
Parse.com tutorial will not help you provide complete workable Facebook solution.
Following are the easiest Steps to integrate Facebook Using Parse
- Go to your manifest file and copy the following in application tag
Android: name="com. Facebook. SDK. ApplicationId "
<activity android: name="com. facebook . FacebookActivity "
"keyboard |keyboardHidden |screenLayout |screenSize |orientation"
- Now go to your Application class and
initilize Facebookutil by usingfollowing line
- Copy the following code in the
activty from where you want to login tofacebook
Finally Copy the following code in the activity from where you want to login tofacebook
Enjoy
Monday, April 20, 2015
ChromeCast Sender Android Application Tutorial (How to Create a chrome Cast application)
Code Source -> Source
Follwing Questions can be answerd in this tutorial
How to get default cast player ID
How to use Cast button on another place then top bar
Easy to Use Cast
Requirements
Just need cast Companion library and place it in same directry as your project
https://github.com/googlecast/CastCompanionLibrary-android
Step1:
Make a new android studio Project
Open Settings File and place follwoing line of code in it
include ':CastCompanionLibrary-android'
project(':CastCompanionLibrary-android').projectDir = new File(rootDir, '../CastCompanionLibrary-android')
Step 2:
Open androidManifiest file and place following code inside it
Permissions
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.INTERNET"/>
CastCompanion Services and activities in manifiest
-> Just chnage the name of parent in below code
<receiver android:name="com.google.android.libraries.cast.companionlibrary.remotecontrol.VideoIntentReceiver" >
<intent-filter>
<action android:name="android.media.AUDIO_BECOMING_NOISY" />
<action android:name="android.intent.action.MEDIA_BUTTON" />
<action android:name="com.google.android.libraries.cast.companionlibrary.action.toggleplayback" />
<action android:name="com.google.android.libraries.cast.companionlibrary.action.stop" />
</intent-filter>
</receiver>
<service
android:name="com.google.android.libraries.cast.companionlibrary.notification.VideoCastNotificationService"
android:exported="false" >
<intent-filter>
<action android:name="com.google.android.libraries.cast.companionlibrary.action.toggleplayback" />
<action android:name="com.google.android.libraries.cast.companionlibrary.action.stop" />
<action android:name="com.google.android.libraries.cast.companionlibrary.action.notificationvisibility" />
</intent-filter>
</service>
<service android:name="com.google.android.libraries.cast.companionlibrary.cast.reconnection.ReconnectionService"/>
<activity
android:name="com.google.android.libraries.cast.companionlibrary.cast.player.VideoCastControllerActivity"
android:label="@string/app_name"
android:launchMode="singleTask"
android:theme="@style/Theme.AppCompat.Light.NoActionBar"
android:parentActivityName="com.example.tahir.castapplication.CastActivity"
android:screenOrientation="portrait" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.example.tahir.castapplication.CastActivity" />
<intent
</intent-filter>
</activity>
Step 3:
Create a new class and Extends it to Application
Paste followings lines in onCreate of Application Class
public void onCreate() {
super.onCreate();
VideoCastManager.
initialize(this, CastMediaControlIntent.DEFAULT_MEDIA_RECEIVER_APPLICATION_ID, null, null).
setVolumeStep(0.5).
enableFeatures(VideoCastManager.FEATURE_NOTIFICATION |
VideoCastManager.FEATURE_LOCKSCREEN |
VideoCastManager.FEATURE_WIFI_RECONNECT |
VideoCastManager.FEATURE_CAPTIONS_PREFERENCE)
;
}
This is the line use to get Default media Player ID in Receiver
CastMediaControlIntent.DEFAULT_MEDIA_RECEIVER_APPLICATION_ID
Open Your Activity XML file and place following code for the button
<android.support.v7.app.MediaRouteButton
android:id="@+id/media_route_button"
android:layout_width="wrap_content"
android:layout_alignParentTop="true"
android:background="@android:color/transparent"
android:layout_height="wrap_content"
android:mediaRouteTypes="user"
/>
If you want to show button in Menu Bar , Paste follwing code in menu file
<item
android:id="@+id/media_route_menu_item"
android:title="Cast"
app:actionProviderClass="android.support.v7.app.MediaRouteActionProvider"
app:showAsAction="always"/>
Step4:
Now open Activity class to register Cll backs
onCreate
mCastManager = VideoCastManager.getInstance();
// -- Adding MiniController
mMini = (MiniController) findViewById(R.id.miniController);
mCastManager.addMiniController(mMini);
mCastManager.addMediaRouterButton(mediaRoutebtn);
mCastConsumer = new VideoCastConsumerImpl() {
@Override
public void onApplicationConnected(ApplicationMetadata appMetadata, String sessionId, boolean wasLaunched) {
Toast.makeText(CastActivity.this,"Successfully Connected to Receiver Application", Toast.LENGTH_LONG).show();
super.onApplicationConnected(appMetadata, sessionId, wasLaunched);
}
@Override
public void onFailed(int resourceId, int statusCode) {
}
@Override
public void onConnectionSuspended(int cause) {
}
@Override
public void onConnectivityRecovered() {
}
@Override
public void onCastDeviceDetected(final MediaRouter.RouteInfo info) {
}
@Override
public void onConnectionFailed(ConnectionResult result) {
}
};
mCastManager.reconnectSessionIfPossible(20);
Line of code to add button on anywhere
mCastManager.addMediaRouterButton(mediaRoutebtn);
OnResume:
protected void onResume() {
super.onResume();
mCastManager = VideoCastManager.getInstance();
mCastManager.addVideoCastConsumer(mCastConsumer);
mCastManager.incrementUiCounter();
}
OnPause
protected void onPause() {
mCastManager.decrementUiCounter();
mCastManager.removeVideoCastConsumer(mCastConsumer);
super.onPause();
}
onDestroy
super.onDestroy();
if (null != mCastManager) {
mMini.removeOnMiniControllerChangedListener(mCastManager);
if(mMini != null) {
mCastManager.removeMiniController(mMini);
}
}
}
Code to add button in onOptionItems
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_cast, menu);
mediaRouteMenuItem = mCastManager.
addMediaRouterButton(menu, R.id.media_route_menu_item);
return true;
}
Now you need to have a function which will start casting any mp4 on you device
private void startCast(){
MediaMetadata mediaMetadata = new MediaMetadata( MediaMetadata.MEDIA_TYPE_MOVIE );
mediaMetadata.putString( MediaMetadata.KEY_TITLE, "Main Title");
mediaMetadata.putString( MediaMetadata.KEY_SUBTITLE, "Sub Title");
mediaMetadata.addImage(new WebImage(Uri.parse(""))); // Cast Icon
mediaMetadata.addImage(new WebImage(Uri.parse(""))); // Wallper
MediaInfo mediaInfo = new MediaInfo.Builder(urlField.getText().toString())
.setContentType("video/mp4") //for live -> "application/vnd.apple.mpegurl"
.setStreamType(MediaInfo.STREAM_TYPE_BUFFERED ) // Repplace for live -> MediaInfo.STREAM_TYPE_LIVE
.setMetadata(mediaMetadata)
.build();
Bundle bundles = com.google.android.libraries.cast.companionlibrary.utils.Utils.mediaInfoToBundle(mediaInfo);
mCastManager.startVideoCastControllerActivity(CastActivity.this,bundles,0,true);
}
If you have any Question let me know,
Source is also attached with the tutorial Code Source
Saturday, February 7, 2015
SuperSU app stuck on KNOX Disabling (Samsung galaxy models KNOX problem)
So here is the simple solution to disable KNOX in samsung phones
Step 1:
Download Terminal Emulator android from google play store
Step 2:
Give it root access by writing
Step 3:
Open Emulator Terminal application and write following command
1-> su 2-> pm disable com . sec . knox . seandroid
Cheers' Now.
Now SuperSu will perfectly ok
Monday, December 1, 2014
Draw Horizontal Bar chart Using Swift (IOS)
We will use UIBezierPath with CAShapeLayer
First of all you need to make a UIVIEWCONTROLL in your app
Next go to viewdidload function and simple
simple call the method to make a bar
How to call
This will simple make a single ..
Comple code to draw Graph(horizontal bar chart)
We will use UIBezierPath with CAShapeLayer
First of all you need to make a UIVIEWCONTROLL in your app
Next go to viewdidload function and simple
simple call the method to make a bar
func drawLine(startpoint start:CGPoint, endpint end:CGPoint, linecolor color: CGColor , linewidth widthline:CGFloat){
var path = UIBezierPath()
path.moveToPoint(start)
path.addLineToPoint(end)
var shapeLayer = CAShapeLayer()
shapeLayer.path = path.CGPath
shapeLayer.strokeColor = color
shapeLayer.lineWidth = widthline
view.layer.addSublayer(shapeLayer)
}
How to call
let start = CGPoint(x:20,y:100)
let end = CGPoint(x:200,y:100)
//red part of line
drawLine(startpoint: start, endpint: end,linecolor: UIColor.redColor().CGColor,linewidth:11.0)
This will simple make a single ..
Comple code to draw Graph(horizontal bar chart)
//
// HorizontalBarChart.swift
// Graphs
//
// Created by tahir fazal hussain on 01/12/2014.
// Copyright (c) 2014 tahir fazal hussain. All rights reserved.
//
import UIKit
class HorizontalBarChart: UIViewController {
var frameWidth = 0
var onePart = 0.0
override func viewDidLoad() {
super.viewDidLoad()
frameWidth = (Int(self.view.frame.width) - 40)
onePart = Double(frameWidth) / Double(100)
NSLog("frame Width %i One Part %d", frameWidth,onePart)
self.view.backgroundColor = UIColor.whiteColor()
drawlines(lineNumber:1, percent:30.0, linename:"Bar1")
drawlines(lineNumber:2, percent:85, linename:"Bar2")
drawlines(lineNumber:3, percent:49.0, linename:"Bar3")
// Do any additional setup after loading the view.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
func drawlines (lineNumber num:Int , percent val:Double,linename name:String){
let startpoint=50
let distance=80
let start = CGPoint(x:20,y:Int(num*distance)+startpoint)
let end = CGPoint(x:Int(val*onePart)+20,y:Int(num*distance)+startpoint)
//first label settings
var lbl = UILabel()
lbl.frame = CGRectMake(start.x, start.y - 25, 55, 15)
lbl.font = lbl.font.fontWithSize(15)
lbl.text = name
view.addSubview(lbl)
//red part of line
drawLine(startpoint: start, endpint: end,linecolor: UIColor.redColor().CGColor,linewidth:11.0)
//gray part of line
let nextpt = Int(Double(100 - val)*onePart) + Int(val*onePart)
let nstart = CGPoint(x:Int(val*onePart)+20,y:Int(num*distance)+startpoint)
let nend = CGPoint(x:nextpt,y:Int(num*distance)+startpoint)
drawLine(startpoint: nstart, endpint: nend, linecolor: UIColor.grayColor().CGColor,linewidth:11.0)
//black vertical line
let vline = CGPoint(x:end.x,y:end.y+5)
let height = CGPoint(x:end.x,y:end.y-30)
drawLine(startpoint: vline, endpint: height, linecolor: UIColor.blackColor().CGColor,linewidth:2.0)
//value label
var lbl2 = UILabel()
//check distance
if ((vline.x + 100 ) > self.view.frame.width ){
lbl2.frame = CGRectMake(vline.x-50, start.y - 25, 50, 15)
}
else{
lbl2.frame = CGRectMake(vline.x+5, start.y - 25, 50, 15)
}
lbl2.font = lbl2.font.fontWithSize(15)
lbl2.text = "value"
view.addSubview(lbl2)
//description value
var lbl3 = UILabel()
lbl3.frame = CGRectMake(start.x+40, start.y + 15, 150, 15)
lbl3.font = lbl3.font.fontWithSize(15)
lbl3.text = "Some Description"
view.addSubview(lbl3)
}
func drawLine(startpoint start:CGPoint, endpint end:CGPoint, linecolor color: CGColor , linewidth widthline:CGFloat){
var path = UIBezierPath()
path.moveToPoint(start)
path.addLineToPoint(end)
var shapeLayer = CAShapeLayer()
shapeLayer.path = path.CGPath
shapeLayer.strokeColor = color
shapeLayer.lineWidth = widthline
view.layer.addSublayer(shapeLayer)
}
/*
// MARK: - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
// Get the new view controller using segue.destinationViewController.
// Pass the selected object to the new view controller.
}
*/
}
Subscribe to:
Posts (Atom)
ad
Top 2 best Torch/Flash/Light/LED Applications for Android
Following are the best torch apps on google play
Super-Rocket LED Torch Light:
This application realy meet the goals for any one wanted an application which support Only torch light.
I figure it out and rant it on first position
Download Super-Rocket Let Torch
Super-Bright LED Flashlight:
I rank this application on 2nd number because it also have others things to play around mean you can change your screen color etc.
Download this app
Following are the best torch apps on google play
Super-Rocket LED Torch Light:
This application realy meet the goals for any one wanted an application which support Only torch light.
I figure it out and rant it on first position
Download Super-Rocket Let Torch
Super-Bright LED Flashlight:
I rank this application on 2nd number because it also have others things to play around mean you can change your screen color etc.
Download this app
How to integrate Facebook With Parse
Parse.com tutorial will not help you provide complete workable Facebook solution.
Following are the easiest Steps to integrate Facebook Using Parse
- Go to your manifest file and copy the following in application tag
Android: name="com. Facebook. SDK. ApplicationId "
<activity android: name="com. facebook . FacebookActivity "
"keyboard |keyboardHidden |screenLayout |screenSize |orientation"
- Now go to your Application class and
initilize Facebookutil by usingfollowing line
- Copy the following code in the
activty from where you want to login tofacebook
Finally Copy the following code in the activity from where you want to login tofacebook
Enjoy
ChromeCast Sender Android Application Tutorial (How to Create a chrome Cast application)
Code Source -> Source
Follwing Questions can be answerd in this tutorial
How to get default cast player ID
How to use Cast button on another place then top bar
Easy to Use Cast
Requirements
Just need cast Companion library and place it in same directry as your project
https://github.com/googlecast/CastCompanionLibrary-android
Step1:
Make a new android studio Project
Open Settings File and place follwoing line of code in it
include ':CastCompanionLibrary-android'
project(':CastCompanionLibrary-android').projectDir = new File(rootDir, '../CastCompanionLibrary-android')
Step 2:
Open androidManifiest file and place following code inside it
Permissions
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.INTERNET"/>
CastCompanion Services and activities in manifiest
-> Just chnage the name of parent in below code
<receiver android:name="com.google.android.libraries.cast.companionlibrary.remotecontrol.VideoIntentReceiver" >
<intent-filter>
<action android:name="android.media.AUDIO_BECOMING_NOISY" />
<action android:name="android.intent.action.MEDIA_BUTTON" />
<action android:name="com.google.android.libraries.cast.companionlibrary.action.toggleplayback" />
<action android:name="com.google.android.libraries.cast.companionlibrary.action.stop" />
</intent-filter>
</receiver>
<service
android:name="com.google.android.libraries.cast.companionlibrary.notification.VideoCastNotificationService"
android:exported="false" >
<intent-filter>
<action android:name="com.google.android.libraries.cast.companionlibrary.action.toggleplayback" />
<action android:name="com.google.android.libraries.cast.companionlibrary.action.stop" />
<action android:name="com.google.android.libraries.cast.companionlibrary.action.notificationvisibility" />
</intent-filter>
</service>
<service android:name="com.google.android.libraries.cast.companionlibrary.cast.reconnection.ReconnectionService"/>
<activity
android:name="com.google.android.libraries.cast.companionlibrary.cast.player.VideoCastControllerActivity"
android:label="@string/app_name"
android:launchMode="singleTask"
android:theme="@style/Theme.AppCompat.Light.NoActionBar"
android:parentActivityName="com.example.tahir.castapplication.CastActivity"
android:screenOrientation="portrait" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.example.tahir.castapplication.CastActivity" />
<intent
</intent-filter>
</activity>
Step 3:
Create a new class and Extends it to Application
Paste followings lines in onCreate of Application Class
public void onCreate() {
super.onCreate();
VideoCastManager.
initialize(this, CastMediaControlIntent.DEFAULT_MEDIA_RECEIVER_APPLICATION_ID, null, null).
setVolumeStep(0.5).
enableFeatures(VideoCastManager.FEATURE_NOTIFICATION |
VideoCastManager.FEATURE_LOCKSCREEN |
VideoCastManager.FEATURE_WIFI_RECONNECT |
VideoCastManager.FEATURE_CAPTIONS_PREFERENCE)
;
}
This is the line use to get Default media Player ID in Receiver
CastMediaControlIntent.DEFAULT_MEDIA_RECEIVER_APPLICATION_ID
Open Your Activity XML file and place following code for the button
<android.support.v7.app.MediaRouteButton
android:id="@+id/media_route_button"
android:layout_width="wrap_content"
android:layout_alignParentTop="true"
android:background="@android:color/transparent"
android:layout_height="wrap_content"
android:mediaRouteTypes="user"
/>
If you want to show button in Menu Bar , Paste follwing code in menu file
<item
android:id="@+id/media_route_menu_item"
android:title="Cast"
app:actionProviderClass="android.support.v7.app.MediaRouteActionProvider"
app:showAsAction="always"/>
Step4:
Now open Activity class to register Cll backs
onCreate
mCastManager = VideoCastManager.getInstance();
// -- Adding MiniController
mMini = (MiniController) findViewById(R.id.miniController);
mCastManager.addMiniController(mMini);
mCastManager.addMediaRouterButton(mediaRoutebtn);
mCastConsumer = new VideoCastConsumerImpl() {
@Override
public void onApplicationConnected(ApplicationMetadata appMetadata, String sessionId, boolean wasLaunched) {
Toast.makeText(CastActivity.this,"Successfully Connected to Receiver Application", Toast.LENGTH_LONG).show();
super.onApplicationConnected(appMetadata, sessionId, wasLaunched);
}
@Override
public void onFailed(int resourceId, int statusCode) {
}
@Override
public void onConnectionSuspended(int cause) {
}
@Override
public void onConnectivityRecovered() {
}
@Override
public void onCastDeviceDetected(final MediaRouter.RouteInfo info) {
}
@Override
public void onConnectionFailed(ConnectionResult result) {
}
};
mCastManager.reconnectSessionIfPossible(20);
Line of code to add button on anywhere
mCastManager.addMediaRouterButton(mediaRoutebtn);
OnResume:
protected void onResume() {
super.onResume();
mCastManager = VideoCastManager.getInstance();
mCastManager.addVideoCastConsumer(mCastConsumer);
mCastManager.incrementUiCounter();
}
OnPause
protected void onPause() {
mCastManager.decrementUiCounter();
mCastManager.removeVideoCastConsumer(mCastConsumer);
super.onPause();
}
onDestroy
super.onDestroy();
if (null != mCastManager) {
mMini.removeOnMiniControllerChangedListener(mCastManager);
if(mMini != null) {
mCastManager.removeMiniController(mMini);
}
}
}
Code to add button in onOptionItems
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_cast, menu);
mediaRouteMenuItem = mCastManager.
addMediaRouterButton(menu, R.id.media_route_menu_item);
return true;
}
Now you need to have a function which will start casting any mp4 on you device
private void startCast(){
MediaMetadata mediaMetadata = new MediaMetadata( MediaMetadata.MEDIA_TYPE_MOVIE );
mediaMetadata.putString( MediaMetadata.KEY_TITLE, "Main Title");
mediaMetadata.putString( MediaMetadata.KEY_SUBTITLE, "Sub Title");
mediaMetadata.addImage(new WebImage(Uri.parse(""))); // Cast Icon
mediaMetadata.addImage(new WebImage(Uri.parse(""))); // Wallper
MediaInfo mediaInfo = new MediaInfo.Builder(urlField.getText().toString())
.setContentType("video/mp4") //for live -> "application/vnd.apple.mpegurl"
.setStreamType(MediaInfo.STREAM_TYPE_BUFFERED ) // Repplace for live -> MediaInfo.STREAM_TYPE_LIVE
.setMetadata(mediaMetadata)
.build();
Bundle bundles = com.google.android.libraries.cast.companionlibrary.utils.Utils.mediaInfoToBundle(mediaInfo);
mCastManager.startVideoCastControllerActivity(CastActivity.this,bundles,0,true);
}
If you have any Question let me know,
Source is also attached with the tutorial Code Source
SuperSU app stuck on KNOX Disabling (Samsung galaxy models KNOX problem)
So here is the simple solution to disable KNOX in samsung phones
Step 1:
Download Terminal Emulator android from google play store
Step 2:
Give it root access by writing
Step 3:
Open Emulator Terminal application and write following command
1-> su 2-> pm disable com . sec . knox . seandroid
Cheers' Now.
Now SuperSu will perfectly ok
Draw Horizontal Bar chart Using Swift (IOS)
We will use UIBezierPath with CAShapeLayer
First of all you need to make a UIVIEWCONTROLL in your app
Next go to viewdidload function and simple
simple call the method to make a bar
How to call
This will simple make a single ..
Comple code to draw Graph(horizontal bar chart)
We will use UIBezierPath with CAShapeLayer
First of all you need to make a UIVIEWCONTROLL in your app
Next go to viewdidload function and simple
simple call the method to make a bar
func drawLine(startpoint start:CGPoint, endpint end:CGPoint, linecolor color: CGColor , linewidth widthline:CGFloat){
var path = UIBezierPath()
path.moveToPoint(start)
path.addLineToPoint(end)
var shapeLayer = CAShapeLayer()
shapeLayer.path = path.CGPath
shapeLayer.strokeColor = color
shapeLayer.lineWidth = widthline
view.layer.addSublayer(shapeLayer)
}
How to call
let start = CGPoint(x:20,y:100)
let end = CGPoint(x:200,y:100)
//red part of line
drawLine(startpoint: start, endpint: end,linecolor: UIColor.redColor().CGColor,linewidth:11.0)
This will simple make a single ..
Comple code to draw Graph(horizontal bar chart)
//
// HorizontalBarChart.swift
// Graphs
//
// Created by tahir fazal hussain on 01/12/2014.
// Copyright (c) 2014 tahir fazal hussain. All rights reserved.
//
import UIKit
class HorizontalBarChart: UIViewController {
var frameWidth = 0
var onePart = 0.0
override func viewDidLoad() {
super.viewDidLoad()
frameWidth = (Int(self.view.frame.width) - 40)
onePart = Double(frameWidth) / Double(100)
NSLog("frame Width %i One Part %d", frameWidth,onePart)
self.view.backgroundColor = UIColor.whiteColor()
drawlines(lineNumber:1, percent:30.0, linename:"Bar1")
drawlines(lineNumber:2, percent:85, linename:"Bar2")
drawlines(lineNumber:3, percent:49.0, linename:"Bar3")
// Do any additional setup after loading the view.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
func drawlines (lineNumber num:Int , percent val:Double,linename name:String){
let startpoint=50
let distance=80
let start = CGPoint(x:20,y:Int(num*distance)+startpoint)
let end = CGPoint(x:Int(val*onePart)+20,y:Int(num*distance)+startpoint)
//first label settings
var lbl = UILabel()
lbl.frame = CGRectMake(start.x, start.y - 25, 55, 15)
lbl.font = lbl.font.fontWithSize(15)
lbl.text = name
view.addSubview(lbl)
//red part of line
drawLine(startpoint: start, endpint: end,linecolor: UIColor.redColor().CGColor,linewidth:11.0)
//gray part of line
let nextpt = Int(Double(100 - val)*onePart) + Int(val*onePart)
let nstart = CGPoint(x:Int(val*onePart)+20,y:Int(num*distance)+startpoint)
let nend = CGPoint(x:nextpt,y:Int(num*distance)+startpoint)
drawLine(startpoint: nstart, endpint: nend, linecolor: UIColor.grayColor().CGColor,linewidth:11.0)
//black vertical line
let vline = CGPoint(x:end.x,y:end.y+5)
let height = CGPoint(x:end.x,y:end.y-30)
drawLine(startpoint: vline, endpint: height, linecolor: UIColor.blackColor().CGColor,linewidth:2.0)
//value label
var lbl2 = UILabel()
//check distance
if ((vline.x + 100 ) > self.view.frame.width ){
lbl2.frame = CGRectMake(vline.x-50, start.y - 25, 50, 15)
}
else{
lbl2.frame = CGRectMake(vline.x+5, start.y - 25, 50, 15)
}
lbl2.font = lbl2.font.fontWithSize(15)
lbl2.text = "value"
view.addSubview(lbl2)
//description value
var lbl3 = UILabel()
lbl3.frame = CGRectMake(start.x+40, start.y + 15, 150, 15)
lbl3.font = lbl3.font.fontWithSize(15)
lbl3.text = "Some Description"
view.addSubview(lbl3)
}
func drawLine(startpoint start:CGPoint, endpint end:CGPoint, linecolor color: CGColor , linewidth widthline:CGFloat){
var path = UIBezierPath()
path.moveToPoint(start)
path.addLineToPoint(end)
var shapeLayer = CAShapeLayer()
shapeLayer.path = path.CGPath
shapeLayer.strokeColor = color
shapeLayer.lineWidth = widthline
view.layer.addSublayer(shapeLayer)
}
/*
// MARK: - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
// Get the new view controller using segue.destinationViewController.
// Pass the selected object to the new view controller.
}
*/
}
Subscribe to:
Posts (Atom)